I'm attempting to read the full contents of a console process (after 3 seconds) with the code below:
Dim NewProcess As New System.Diagnostics.Process()
With NewProcess.StartInfo
.FileName = EXE_PATH
.RedirectStandardOutput = True
.RedirectStandardError = True
.RedirectStandardInput = True
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Normal
.CreateNoWindow = False
End With
NewProcess.Start()
System.Threading.Thread.Sleep(3000)
MsgBox(NewProcess.StandardOutput.ReadToEnd)
However, the application seems to pause when attempting to 'ReadToEnd', I think this is because the console process is a continuous output and is never going to actually end. 'ReadLine' works fine, but only gets the first line, but I need the entire contents of the console at that stage.
How can I solve this problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…