Dim myprocess As New Process
Dim StartInfo As New System.Diagnostics.ProcessStartInfo
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
StartInfo.FileName = "apo.exe"
StartInfo.RedirectStandardInput = True
StartInfo.RedirectStandardOutput = True
StartInfo.CreateNoWindow = True
StartInfo.UseShellExecute = False
myprocess.StartInfo = StartInfo
myprocess.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
myprocess.StandardInput.WriteLine(txtCommand.Text)
'------------------------------------------------------
'If I do.close,process apo.exe will close.else ReadToEnd will hangs &can't read any string
myprocess.StandardInput.Close()
'------------------------------------------------------
txtResults.Text = myprocess.StandardOutput.ReadToEnd
End Sub
there is a console program named "apo.exe",I just want to send some command to "apo.exe" and get returns. The question is when my code running at 'StandardInput.Close',apo.exe will closed.I have to send commands continuously with it running. What should I do?