[英]How to prevent a process started by Process.Start() from exiting when my app exits?
my method... 我的方法
private static void RunAndExit(string command)
{
var processInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/c " + command,
CreateNoWindow = false,
UseShellExecute = true,
RedirectStandardError = false,
RedirectStandardOutput = false
};
}
I want the process started by RunAndExit() to continue to run after the app containing this method has exited. 我希望由RunAndExit()启动的进程在退出包含此方法的应用程序后继续运行。 Thanks for any help! 谢谢你的帮助!
Your code will already achieve that, so long as you actually start the new process. 只要您实际启动新过程,您的代码就已经可以实现该目标。 You are missing a call to Process.Start()
. 您缺少对Process.Start()
的调用。
private static void RunAndExit(string command)
{
var processInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
....
};
Process.Start(processInfo); // add this line
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.