devilgoblin
Member
This code seems to be accurate when comparing to the many examples that are similar on different forums and I would think it should work:
Dim pC As New Process
pC.StartInfo.CreateNoWindow = True
pC.StartInfo.RedirectStandardOutput = True
pC.StartInfo.UseShellExecute = False
pC.StartInfo.FileName = Application.StartupPath & "\build.bat"
AddHandler pC.OutputDataReceived, AddressOf pC_OutputDataReceived
pC.Start()
pC.BeginOutputReadLine()
pC.WaitForExit()
Private Sub pC_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
lbOutput.Items.Add(e.Data.ToString)
End Sub
When I remove the pC.BeginOutputReadLine() command, the application continues to function, but nothing is added to lbOutput.
With the pC.BeginOutputReadLine() command, it gives the error "vshost.exe has stopped working"
Either way, my batch file does what its supposed to do. Any one have any ideas what I am doing wrong with the process?
Dim pC As New Process
pC.StartInfo.CreateNoWindow = True
pC.StartInfo.RedirectStandardOutput = True
pC.StartInfo.UseShellExecute = False
pC.StartInfo.FileName = Application.StartupPath & "\build.bat"
AddHandler pC.OutputDataReceived, AddressOf pC_OutputDataReceived
pC.Start()
pC.BeginOutputReadLine()
pC.WaitForExit()
Private Sub pC_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
lbOutput.Items.Add(e.Data.ToString)
End Sub
When I remove the pC.BeginOutputReadLine() command, the application continues to function, but nothing is added to lbOutput.
With the pC.BeginOutputReadLine() command, it gives the error "vshost.exe has stopped working"
Either way, my batch file does what its supposed to do. Any one have any ideas what I am doing wrong with the process?