2016-12-23 9 views
0

cmdにパスと引数を送信しようとしています。 私はCで書いています# しかし、それは動作しません。 助けていただければ幸いです。cmdへのパスと引数を送信

マイコード:

string path = @"C:\Users\SAMSUNG\Documents\Visual Studio 2015\Projects\phantom\phantom\bin\Debug\phantom"; 

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 = " \"" + path + "\" /c -phantomjs screentaker.js "; 
process.StartInfo = startInfo; 
process.Start(); 
+0

実行可能ファイルのパスを引数ではありません。そのパスを 'startInfo.WorkingDirectory'に設定してください – Pikoh

+0

実行しようとしているコマンドはなんですか? 「C:¥Users¥SAMSUNG¥Documents¥Visual Studio 2015¥Projects¥ファントム¥ファントム¥bin¥Debug¥phantom.exe -phantomjs screentaker.js'ですか? – Pikoh

+0

はいコードを実行しようとしています。 – muzosahin

答えて

0

実行可能ファイルのパスを引数ではなく、FileNamecmd.exeすべきではありません。これを試してみてください:

string path = @"C:\Users\SAMSUNG\Documents\Visual Studio 2015\Projects\phantom\phantom\bin\Debug\phantom.exe"; 
System.Diagnostics.Process process = new System.Diagnostics.Process(); 
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); 
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
startInfo.FileName = path; 

startInfo.Arguments = "-phantomjs screentaker.js"; 
process.StartInfo = startInfo; 
process.Start(); 

あなたがcmd.exeを使用して主張する場合、これはうまくいくかもしれない:

string path = @"C:\Users\SAMSUNG\Documents\Visual Studio 2015\Projects\phantom\phantom\bin\Debug\phantom.exe"; 

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 " + path + " -phantomjs screentaker.js "; 
process.StartInfo = startInfo; 
process.Start(); 
+0

多くの感謝がありますが、working.iはcmdを使用していないので、パスとスクリプトを実行する必要があります。 – muzosahin

関連する問題