我从当前的C#应用程序调用新进程(C#应用程序),我使用:
Process proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/c "+filePath;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
我可以在任务管理器中看到新进程,但它会立即终止
我用代码解决了这个问题:
ProcessStartInfo psi = new ProcessStartInfo();
psi.WorkingDirectory = Path.GetDirectoryName(filePath);
psi.FileName = filePath;
psi.ErrorDialog = true;
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
Process proc = Process.Start(psi);
https://stackoverflow.com/questions/52154551
复制相似问题