Look for an example C # WinForms application showing output from a batch file

I am looking for a WinForms C # application sample project that redirects output from a batch file that runs in the background to any WinForms control.

Any suggestions?

+4
source share
2 answers

I do not know if you are going to find a direct example, but it is not too difficult. I don’t have time to write all the code for you, but I can give you the code from MSDN:

Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("C:\\MyBatchFile.bat" ); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.RedirectStandardOutput = true; myProcess.StartInfo = myProcessStartInfo; myProcess.Start(); StreamReader myStreamReader = myProcess.StandardOutput; // Read the standard output of the spawned process. string myString = myStreamReader.ReadToEnd(); myProcess.Close(); // Now you have the output of the batch file in myString 
+6
source

See here.

It will show you how to redirect output to an event. Then you can take the conclusion and put it in your control of the victory.

+1
source

Source: https://habr.com/ru/post/1313201/


All Articles