B
brianbasquille
Hello all,
Hope you can help me with this little conundrum!
I'm running a batch file and want to print the execution of it
line-by-line.
Best reference i could find was:
http://www.developerfusion.co.uk/show/4662/
- it's in VB but pretty much identical to the C#. But this only prints
the output of the batch file at the end.
Tried to manipulate it to work with mine to print line by line but it
either says the process has finished or it simply fails.
// start code
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="temp.bat";
proc.StartInfo.RedirectStandardOutput=true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
while(proc.Responding)
MessageBox.Show(proc.StandardOutput.ReadLine());
File.Delete("temp.bat");
// end code
Tried putting the WaitForExit() command after the while block which
didn't work either.
Any suggestions or pointers on how to get this working?
Thanks in advance,
Brian
Hope you can help me with this little conundrum!
I'm running a batch file and want to print the execution of it
line-by-line.
Best reference i could find was:
http://www.developerfusion.co.uk/show/4662/
- it's in VB but pretty much identical to the C#. But this only prints
the output of the batch file at the end.
Tried to manipulate it to work with mine to print line by line but it
either says the process has finished or it simply fails.
// start code
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="temp.bat";
proc.StartInfo.RedirectStandardOutput=true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
while(proc.Responding)
MessageBox.Show(proc.StandardOutput.ReadLine());
File.Delete("temp.bat");
// end code
Tried putting the WaitForExit() command after the while block which
didn't work either.
Any suggestions or pointers on how to get this working?
Thanks in advance,
Brian