我正在尝试在C#中的另一个exe文件中运行一个exe文件

效果很好,但是我的问题是应该在另一个内部运行的exe打开另一个控制台窗口,我需要在其中按下“ Enter”,以使其在完成操作后停止。

有没有办法做到这一点?

这是我到目前为止的代码。

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


谢谢

最佳答案

只需使用cmd打开并终止exe /用户窗口即可。

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

关于c# - 从另一个exe C#运行一个exe并关闭它,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33144819/

10-17 02:40