2012-03-21 31 views
0

C#プログラムからの引数を使用してesriRegAsm.exeを呼び出そうとしています。 目的はDllを登録することです。したがって、私は通常、引数としてDllといくつかの追加パラメータ(/ p:Desktop/s)を指定してesriRegAsm.exeを呼び出します。これはcmd.exeに入力するとうまく動作します。どうやら、私は、プロセスが引数リスト全体ではなくcmdに最初の文字列だけを送ると思っていますが、パスの空白文字には ""が必要です。 デバッグ用にメッセージボックスを追加しましたが、文字列は大丈夫です。C#プロセスによるcmd.exeによる複数の引数

バックスラッシュまたはダブルバックスラッシュは重要ではないようです。私はメッセージボックスの写真をアタッシェないよう

 string targetDir = this.Context.Parameters["targ"]; 
     string programFilesFolder = this.Context.Parameters["proFiles"]; 

     System.Diagnostics.Process process = new System.Diagnostics.Process(); 
     System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); 
     startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
     startInfo.FileName = "cmd.exe"; 
     startInfo.Arguments = "/C \"" + programFilesFolder + "Common Files\\\\ArcGIS\\\\bin\\\\esriRegAsm.exe\" " + "\"" + targetDir + "RArcGISTest.dll\" /p:Desktop /s"; 
     MessageBox.Show("/C \"" + programFilesFolder + "Common Files\\\\ArcGIS\\\\bin\\\\esriRegAsm.exe\" " + "\"" + targetDir + "RArcGISTest.dll\" /p:Desktop /s"); 
     process.StartInfo = startInfo; 
     process.Start(); 

...出力は次のようになります。

/C「C:\プログラムファイル(x86の)\ CommonのFiles \ ArcGISの\ binに\ esriRegAsm.exe " "C:\ \ RArcGISTest.dllインストール"/ Pを:デスクトップ/ sの"

+0

質問は...? –

+0

...それを働かせる方法 – steffan

答えて

1

だけで直接処理を行うなぜあなたはダブルエスケープのものであり、なぜあなたはcmd.exeを通してそれをルーティングしている:

string targetDir = this.Context.Parameters["targ"]; 
string programFilesFolder = this.Context.Parameters["proFiles"]; 

Process process = new Process(); 
ProcessStartInfo startInfo = new ProcessStartInfo(); 
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
startInfo.FileName = Path.Combine(programFilesFolder, @"Common Files\ArcGIS\bin\esriRegAsm.exe"); 
startInfo.Arguments = "\"" + Path.Combine(targetDir, "RArcGISTest.dll") + "\" /p:Desktop /s"; 
process.StartInfo = startInfo; 
process.Start(); 
を?
+0

私のために働く:)ありがとう...私はtargetDirの文字列のための何かを似たように見たので私はそれをエスケープした。そして、はい、それはコマンドラインを使用するのは馬鹿です。 – steffan

関連する問題