2015-10-15 123 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);