Hi I use this code below that can capture dos outputs.
This code works well for capturing most things were you do not have to wait long.
Now I want to do the same for netstat the only problem I have to wait a while for it to capture the output
What I want to know is there a way to make my function read in each line as it comes in
so if I was to use netstat -a -f , it will list each IP in a list box
Thanks.
Code:
Private Function CaptureDos(ByVal Filename As String, Optional ByVal Parms As String = vbNullString) As String
Dim Exec As New System.Diagnostics.Process()
Dim Buffer As String = vbNullString
Try
With Exec
.StartInfo.RedirectStandardOutput = True
.StartInfo.UseShellExecute = False
.StartInfo.CreateNoWindow = True
.StartInfo.FileName = Filename
.StartInfo.Arguments = Parms
.Start()
'Read in output.
Buffer = .StandardOutput.ReadToEnd()
'Wait for exit.
Exec.WaitForExit()
'Return string.
Return Buffer
End With
Catch ex As Exception
Return vbNullString
End Try
End Function
Now I want to do the same for netstat the only problem I have to wait a while for it to capture the output
What I want to know is there a way to make my function read in each line as it comes in
so if I was to use netstat -a -f , it will list each IP in a list box
Thanks.