I'm calling a batch file in my C# program. But the batch file has that "pause" so I get the "Press any key to continue" window. I cannot edit the batch file. Is there a way to skip this? I'm using the code below(found in this SO answer) and played around with it - but without luck.
Thank you everyone in advance.
int exitCode;
string command = "test.bat"
ProcessStartInfo processInfo;
Process process;
string path = @"C:\test\test";
processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
processInfo.WorkingDirectory = path;
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
exitCode = process.ExitCode;
MessageBox.Show("output>>" + (String.IsNullOrEmpty(output) ? "(press any key to continue...)" : output));
MessageBox.Show("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
MessageBox.Show("ExitCode: " + exitCode.ToString(), "ExecuteCommand");
process.Close();