保持一个新的进程中打开控制台窗口为完成后 [英] Keep console window of a new Process open after it finishes
本文介绍了保持一个新的进程中打开控制台窗口为完成后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前有创建一个新的进程,并从shell执行它的代码的一部分。
I currently have a portion of code that creates a new Process and executes it from the shell.
Process p = new Process();
...
p.Start();
p.WaitForExit();
这保持窗口打开,而进程正在运行,这是伟大的。不过,我也想保持窗口打开的之后的它完成可以查看潜在的消息。有没有办法做到这一点?
This keeps the window open while the process is running, which is great. However, I also want to keep the window open after it finishes to view potential messages. Is there a way to do this?
推荐答案
这将打开外壳,开始你的可执行文件,并保持在shell窗口打开时,过程结束
This will open the shell, start your executable and keep the shell window open when the process ends
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "CMD.EXE";
psi.Arguments = "/K yourmainprocess.exe";
p.Start(psi);
p.WaitForExit();
这篇关于保持一个新的进程中打开控制台窗口为完成后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文