2015-10-15 122 views
2

我試圖運行內的另一個exe文件exe文件在C#從另一個EXE C#運行exe文件,並關閉它

行之有效,但我的問題是,應該在其他內部運行exe打開另一個控制檯窗口,我需要按下「Enter」鍵,讓它在完成它的操作後停止。

有沒有辦法做到這一點?

這是我到目前爲止的代碼。

var proc = new Process(); 
proc.StartInfo.FileName = "thefile.exe"; 
proc.Start(); 
proc.WaitForExit(); 
var exitCode = proc.ExitCode; 
proc.Close(); 

感謝

回答

2

只需使用CMD打開和TERMINAT exe文件/用戶窗口。

string executingCommand; 
executingCommand= "/C Path\\To\\Your\\.exe"; // the /C terminates after carrying out the command 
System.Diagnostics.Process.Start("CMD.exe", executingCommand);