0

I'm using a Windows form I created in C# to execute a batch file. The batch file runs, and the cmd window appears, but the window is blank and does not display any of the commands the batch file is executing. Is there a way I can make the CMD window display what it is doing? Relevant code snippet below.

var processInfo = new ProcessStartInfo("cmd.exe", "/c " + "\"C:\\tf_Test2.bat\"");
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
var process = Process.Start(processInfo);
process.WaitForExit();
Skadwick
  • 37
  • 3
  • Possible duplicate of [How do I use ProcessStartInfo to run a batch file?](https://stackoverflow.com/questions/2382683/how-do-i-use-processstartinfo-to-run-a-batch-file) – Hackerman Jun 11 '18 at 18:25

1 Answers1

2

Change UseShellExecute to true and drop support for redirecting the output streams. In effect you are telling Windows that you don't want the output to go to the console window.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445