Hi! I'm using Visual Basic 2008 Professional Edition and I'm having a problem that i really don't know if can even be solved.
I'm doing an application that sends to the command line a tracert command, and analyse the output. I'm using the following code:
Everything is working perfectly... But, the tracert command can take several minutes to finish the trace.
So, when there is a trace where all the hops are fine, it's ok, but when i trace an IP and there will be a lot of "request timed out", this can take around 7 minutes...
The problem is that i can´t stop the process. Once started, I just can't do any action. The application just stops (and if i choose other window, the message "Not responding..." is shown in the title of the application) and only allow me to do something when the process is completed...
So i would like to know if there is a way to put the command line process runing in background (or any other solution) so i can put there a button that allows the command line to stop.
Thanks!
I'm sorry for my horrible english.
I'm doing an application that sends to the command line a tracert command, and analyse the output. I'm using the following code:
Code:
Public Function ProcessStartAndCaptureOutput(ByVal CmdFile As String, ByVal args As String) As String
Dim p As Diagnostics.Process = New Diagnostics.Process
p.StartInfo.FileName = CmdFile
p.StartInfo.Arguments = args
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.CreateNoWindow = True
p.Start()
Return p.StandardOutput.ReadToEnd
End Function
Code:
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
outputcmd.Text = ProcessStartAndCaptureOutput("tracert", TextBox3.Text)
End Sub
Everything is working perfectly... But, the tracert command can take several minutes to finish the trace.
So, when there is a trace where all the hops are fine, it's ok, but when i trace an IP and there will be a lot of "request timed out", this can take around 7 minutes...
The problem is that i can´t stop the process. Once started, I just can't do any action. The application just stops (and if i choose other window, the message "Not responding..." is shown in the title of the application) and only allow me to do something when the process is completed...
So i would like to know if there is a way to put the command line process runing in background (or any other solution) so i can put there a button that allows the command line to stop.
Thanks!
I'm sorry for my horrible english.