Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

 

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

 

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...