Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

Capture Netstat output

$
0
0
Hi I use this code below that can capture dos outputs.

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

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.

Viewing all articles
Browse latest Browse all 27329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>