It's a little bit complicated problem. I have tried probably everything and still no working. I run WinForm application from I run CMD and next run another app(console application) on cmd. It's working on /c START xyz but when app finished CMD always is closing. I want to pause this window.
ProcessStartInfo processInfo = new ProcessStartInfo { FileName = "cmd.exe", WorkingDirectory = Path.GetDirectoryName(YourApplicationPath), Arguments = "/K START " + cmdparametr, RedirectStandardOutput = true, RedirectStandardInput = true, RedirectStandardError = true, CreateNoWindow = false, UseShellExecute = false, WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal, }; Process p = new Process { StartInfo = processInfo }; p.Start(); int ExitCode; p.WaitForExit(); // *** Read the streams *** string output = p.StandardOutput.ReadToEnd(); string error = p.StandardError.ReadToEnd(); ExitCode = p.ExitCode; MessageBox.Show("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output)); MessageBox.Show("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error)); MessageBox.Show("ExitCode: " + ExitCode.ToString(), "ExecuteCommand"); p.Close(); ReadStream is working when I add argument: START /b but I think it's not important.
WaitForExit() doesn't work.
Is it possible to pause application through command maybe like this: /k start xyz.exe & PAUSE?
My app is console application!
& pauseto the end of your command as your question notes? Perhaps related - is there any reason you are redirecting input?