473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to create mutliple instances of Tracert in VB.NET to run at thesame time

Hi,

I currently have some basic code that allows me to run the tracert
command through VB.NET and it also updates my database based on the
results.
I was wondering if someone can help me find a way that I can used my
code to run tracert on mutiple instances at the same time. The
following is my current code.
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click
' start NT tracert command
Dim ExeFileName As String
Dim Arguments As String
ExeFileName = "tracert"
Arguments = txtRoute.Text & " -h 5"
Dim s As String
Dim p As New Process
With p.StartInfo
.WorkingDirectory = "C:\windows\system32"
.FileName = ExeFileName
.Arguments = Arguments
.UseShellExecute = False
.RedirectStandardError = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.WindowStyle = ProcessWindowStyle.Hidden
.CreateNoWindow = True
End With
Try
p.Start()
s = p.StandardOutput.ReadToEnd()
p.WaitForExit()
Catch ex As Exception
s = ex.ToString
End Try
p.Dispose()
Dim test As String
Dim r As Integer
Dim rtimout As Single
Dim sever As Single
Dim devicname As String
Dim alrstr As String
'Determine Link State
rtimout = 0
test = s.ToString
r = test.IndexOf("192.168.101.2")
If r 0 Then
lblStatus.Text = "STATUS: Link to CORP is FSO"
sever = 1
devicname = "FSO"
alrstr = "Primary Route FSO is UP"
SqlSelectInsert(sever, devicname, alrstr)
ElseIf Not r 0 Then
r = test.IndexOf("192.168.11.21")
If r 0 Then
lblStatus.Text = "STATUS: Link to Site1 is Router1"
sever = 2
devicname = "Radio"
alrstr = "Secondary Route is UP, Primary Route is
down"
SqlSelectInsert(sever, devicname, alrstr)
ElseIf Not r 0 Then
r = test.IndexOf("timed out")
lblStatus.Text = "STATUS: Link is Down"
If r 0 Then
sever = 3
devicname = "NetworkDown"
alrstr = "The Network is Down
SqlSelectInsert(sever, devicname, alrstr)
End If
End If
End If
'MessageBox.Show(s.ToString())
End Sub
Public Function SqlSelectInsert(ByVal sever As String, ByVal
devicname As String, ByVal alrstr As String) As String
'Create SQL Connection
Dim sqlResult As String
Dim sqlCon As New System.Data.SqlClient.SqlConnection
Dim sConnStr As String
sConnStr = "server=myserver
\nmssse;uid=test;pwd=test12345;database=test_Datab ase"
sqlCon.ConnectionString = sConnStr
' Query the database before making and entry
sqlCon.Open()
Dim sqlcommand As New System.Data.SqlClient.SqlCommand
sqlcommand.CommandType = CommandType.StoredProcedure
sqlcommand.CommandText = "dbo.Select_LastRouteEntry"
sqlcommand.Connection = sqlCon
Dim sqlDataReader As System.Data.SqlClient.SqlDataReader
sqlDataReader = sqlcommand.ExecuteReader
If sqlDataReader.HasRows Then
While sqlDataReader.Read
sqlResult =
sqlDataReader.GetString(sqlDataReader.GetOrdinal(" devname"))
End While
End If
sqlCon.Close()
If Not devicname = sqlResult Then
sqlCon.Open()
Dim sqlCommand2 As New System.Data.SqlClient.SqlCommand
sqlCommand2.CommandType = CommandType.StoredProcedure
sqlCommand2.CommandText = "dbo.Insert_Route_Info"
sqlCommand2.Connection = sqlCon
sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sever", sever))
sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@devname", devicname))
sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@alrstr", alrstr))
sqlCommand2.ExecuteNonQuery()
sqlCon.Close()
End If
Return True
End Function
Thank you in advance
Apr 5 '08 #1
2 2002
On Apr 4, 5:54*pm, whitethoma...@gmail.com wrote:
Hi,

I currently have some basic code that allows me to run the tracert
command through VB.NET and it also updates my database based on the
results.

I was wondering if someone can help me find a way that I can used my
code to run tracert on mutiple instances at the same time. *The
following is my current code.

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click
* * * * ' start NT tracert command
* * * * Dim ExeFileName As String
* * * * Dim Arguments As String
* * * * ExeFileName = "tracert"
* * * * Arguments = txtRoute.Text & " -h 5"
* * * * Dim s As String
* * * * Dim p As New Process
* * * * With p.StartInfo
* * * * * * .WorkingDirectory = "C:\windows\system32"
* * * * * * .FileName = ExeFileName
* * * * * * .Arguments = Arguments
* * * * * * .UseShellExecute = False
* * * * * * .RedirectStandardError = True
* * * * * * .RedirectStandardInput = True
* * * * * * .RedirectStandardOutput = True
* * * * * * .WindowStyle = ProcessWindowStyle.Hidden
* * * * * * .CreateNoWindow = True
* * * * End With
* * * * Try
* * * * * * p.Start()
* * * * * * s = p.StandardOutput.ReadToEnd()
* * * * * * p.WaitForExit()
* * * * Catch ex As Exception
* * * * * * s = ex.ToString
* * * * End Try
* * * * p.Dispose()
* * * * Dim test As String
* * * * Dim r As Integer
* * * * Dim rtimout As Single
* * * * Dim sever As Single
* * * * Dim devicname As String
* * * * Dim alrstr As String
* * * * 'Determine Link State
* * * * rtimout = 0
* * * * test = s.ToString
* * * * r = test.IndexOf("192.168.101.2")
* * * * If r 0 Then
* * * * * * lblStatus.Text = "STATUS: Link to CORP is FSO"
* * * * * * sever = 1
* * * * * * devicname = "FSO"
* * * * * * alrstr = "Primary Route FSO is UP"
* * * * * * SqlSelectInsert(sever, devicname, alrstr)
* * * * ElseIf Not r 0 Then
* * * * * * r = test.IndexOf("192.168.11.21")
* * * * * * If r 0 Then
* * * * * * * * lblStatus.Text = "STATUS: Link to Site1 is Router1"
* * * * * * * * sever = 2
* * * * * * * * devicname = "Radio"
* * * * * * * * alrstr = "Secondary Route is UP, PrimaryRoute is
down"
* * * * * * * * SqlSelectInsert(sever, devicname, alrstr)
* * * * * * ElseIf Not r 0 Then
* * * * * * * * r = test.IndexOf("timed out")
* * * * * * * * lblStatus.Text = "STATUS: Link is Down"
* * * * * * * * If r 0 Then
* * * * * * * * * * sever = 3
* * * * * * * * * * devicname = "NetworkDown"
* * * * * * * * * * alrstr = "The Network is Down
* * * * * * * * * * SqlSelectInsert(sever, devicname, alrstr)
* * * * * * * * End If
* * * * * * End If
* * * * End If
* * * * 'MessageBox.Show(s.ToString())
* * End Sub
* * Public Function SqlSelectInsert(ByVal sever As String, ByVal
devicname As String, ByVal alrstr As String) As String
* * * * 'Create SQL Connection
* * * * Dim sqlResult As String
* * * * Dim sqlCon As New System.Data.SqlClient.SqlConnection
* * * * Dim sConnStr As String
* * * * sConnStr = "server=myserver
\nmssse;uid=test;pwd=test12345;database=test_Datab ase"
* * * * sqlCon.ConnectionString = sConnStr
* * * * ' Query the database before making and entry
* * * * sqlCon.Open()
* * * * Dim sqlcommand As New System.Data.SqlClient.SqlCommand
* * * * sqlcommand.CommandType = CommandType.StoredProcedure
* * * * sqlcommand.CommandText = "dbo.Select_LastRouteEntry"
* * * * sqlcommand.Connection = sqlCon
* * * * Dim sqlDataReader As System.Data.SqlClient.SqlDataReader
* * * * sqlDataReader = sqlcommand.ExecuteReader
* * * * If sqlDataReader.HasRows Then
* * * * * * While sqlDataReader.Read
* * * * * * * * sqlResult =
sqlDataReader.GetString(sqlDataReader.GetOrdinal(" devname"))
* * * * * * End While
* * * * End If
* * * * sqlCon.Close()
* * * * If Not devicname = sqlResult Then
* * * * * * sqlCon.Open()
* * * * * * Dim sqlCommand2 As New System.Data.SqlClient.SqlCommand
* * * * * * sqlCommand2.CommandType = CommandType.StoredProcedure
* * * * * * sqlCommand2.CommandText = "dbo.Insert_Route_Info"
* * * * * * sqlCommand2.Connection = sqlCon
* * * * * * sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sever", sever))
* * * * * * sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@devname", devicname))
* * * * * * sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@alrstr", alrstr))
* * * * * * sqlCommand2.ExecuteNonQuery()
* * * * * * sqlCon.Close()
* * * * End If
* * * * Return True
* * End Function

Thank you in advance
HI,

After thinking about my request, I thinking that maybe utilizing
timers will work but I am unsure on how to do it to allow it to be
dynamic. What I mean by dydnamic is to allow an end user to select a
property and then set how the laps time between each instance. Some
instances should be able to run at the same time while others on
different times. For example:

1. Route 1 is checked every minute
2. Route 2 is also checked every minute
3. Route 3 is checked every 5 minutes

Is it possible that someone can post some sample code to just get me
started. It would be greatly appreciated

Thank You
Apr 5 '08 #2
On Apr 5, 11:32*am, whitethoma...@gmail.com wrote:
On Apr 4, 5:54*pm, whitethoma...@gmail.com wrote:


Hi,
I currently have some basic code that allows me to run the tracert
command through VB.NET and it also updates my database based on the
results.
I was wondering if someone can help me find a way that I can used my
code to run tracert on mutiple instances at the same time. *The
following is my current code.
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click
* * * * ' start NT tracert command
* * * * Dim ExeFileName As String
* * * * Dim Arguments As String
* * * * ExeFileName = "tracert"
* * * * Arguments = txtRoute.Text & " -h 5"
* * * * Dim s As String
* * * * Dim p As New Process
* * * * With p.StartInfo
* * * * * * .WorkingDirectory = "C:\windows\system32"
* * * * * * .FileName = ExeFileName
* * * * * * .Arguments = Arguments
* * * * * * .UseShellExecute = False
* * * * * * .RedirectStandardError = True
* * * * * * .RedirectStandardInput = True
* * * * * * .RedirectStandardOutput = True
* * * * * * .WindowStyle = ProcessWindowStyle.Hidden
* * * * * * .CreateNoWindow = True
* * * * End With
* * * * Try
* * * * * * p.Start()
* * * * * * s = p.StandardOutput.ReadToEnd()
* * * * * * p.WaitForExit()
* * * * Catch ex As Exception
* * * * * * s = ex.ToString
* * * * End Try
* * * * p.Dispose()
* * * * Dim test As String
* * * * Dim r As Integer
* * * * Dim rtimout As Single
* * * * Dim sever As Single
* * * * Dim devicname As String
* * * * Dim alrstr As String
* * * * 'Determine Link State
* * * * rtimout = 0
* * * * test = s.ToString
* * * * r = test.IndexOf("192.168.101.2")
* * * * If r 0 Then
* * * * * * lblStatus.Text = "STATUS: Link to CORP is FSO"
* * * * * * sever = 1
* * * * * * devicname = "FSO"
* * * * * * alrstr = "Primary Route FSO is UP"
* * * * * * SqlSelectInsert(sever, devicname, alrstr)
* * * * ElseIf Not r 0 Then
* * * * * * r = test.IndexOf("192.168.11.21")
* * * * * * If r 0 Then
* * * * * * * * lblStatus.Text = "STATUS: Link to Site1 is Router1"
* * * * * * * * sever = 2
* * * * * * * * devicname = "Radio"
* * * * * * * * alrstr = "Secondary Route is UP, Primary Route is
down"
* * * * * * * * SqlSelectInsert(sever, devicname, alrstr)
* * * * * * ElseIf Not r 0 Then
* * * * * * * * r = test.IndexOf("timed out")
* * * * * * * * lblStatus.Text = "STATUS: Link is Down"
* * * * * * * * If r 0 Then
* * * * * * * * * * sever = 3
* * * * * * * * * * devicname = "NetworkDown"
* * * * * * * * * * alrstr = "The Network is Down
* * * * * * * * * * SqlSelectInsert(sever, devicname, alrstr)
* * * * * * * * End If
* * * * * * End If
* * * * End If
* * * * 'MessageBox.Show(s.ToString())
* * End Sub
* * Public Function SqlSelectInsert(ByVal sever As String, ByVal
devicname As String, ByVal alrstr As String) As String
* * * * 'Create SQL Connection
* * * * Dim sqlResult As String
* * * * Dim sqlCon As New System.Data.SqlClient.SqlConnection
* * * * Dim sConnStr As String
* * * * sConnStr = "server=myserver
\nmssse;uid=test;pwd=test12345;database=test_Datab ase"
* * * * sqlCon.ConnectionString = sConnStr
* * * * ' Query the database before making and entry
* * * * sqlCon.Open()
* * * * Dim sqlcommand As New System.Data.SqlClient.SqlCommand
* * * * sqlcommand.CommandType = CommandType.StoredProcedure
* * * * sqlcommand.CommandText = "dbo.Select_LastRouteEntry"
* * * * sqlcommand.Connection = sqlCon
* * * * Dim sqlDataReader As System.Data.SqlClient.SqlDataReader
* * * * sqlDataReader = sqlcommand.ExecuteReader
* * * * If sqlDataReader.HasRows Then
* * * * * * While sqlDataReader.Read
* * * * * * * * sqlResult =
sqlDataReader.GetString(sqlDataReader.GetOrdinal(" devname"))
* * * * * * End While
* * * * End If
* * * * sqlCon.Close()
* * * * If Not devicname = sqlResult Then
* * * * * * sqlCon.Open()
* * * * * * Dim sqlCommand2 As New System.Data.SqlClient.SqlCommand
* * * * * * sqlCommand2.CommandType = CommandType.StoredProcedure
* * * * * * sqlCommand2.CommandText = "dbo.Insert_Route_Info"
* * * * * * sqlCommand2.Connection = sqlCon
* * * * * * sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sever", sever))
* * * * * * sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@devname", devicname))
* * * * * * sqlCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@alrstr", alrstr))
* * * * * * sqlCommand2.ExecuteNonQuery()
* * * * * * sqlCon.Close()
* * * * End If
* * * * Return True
* * End Function
Thank you in advance

HI,

After thinking about my request, I thinking that maybe utilizing
timers will work but I am unsure on how to do it to allow it to be
dynamic. What I mean by dydnamic is to allow an end user to select a
property and then set how the laps time between each instance. *Some
instances should be able to run at the same time while others on
different times. *For example:

1. *Route 1 is checked every minute
2. Route 2 is also checked every minute
3. *Route 3 is checked every 5 minutes

Is it possible that someone can post some sample code to just get me
started. *It would be greatly appreciated

Thank You- Hide quoted text -

- Show quoted text -
P.S. My project is database driven so the number of objects can
change...Please help
Apr 5 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: carramba | last post by:
Hi! Iam runing php on win32.. and Iam wondering if there is enyposibility to run tracert in php? if yes how should I do it? -- just keep swiming
1
by: Paul Bergson | last post by:
I need to code a tracert function from an asp page. I can write some asp but I'm saddled with notepad as my development suite. Any pointers on getting a tracert type function from within asp? ...
4
by: Just D. | last post by:
We all know that we can use TRACERT as a standalone application in Windows to get a whole way of IP nodes to go through. I need to implement almost same feature from my own application. What's the...
2
by: Markus Prediger | last post by:
Hi NG, I have an asp.net project that uses an vb6 com object for some database-manipulation (I cannot rewrite it in .net, sorry, its not my decision). I want it to be instanciated seperately...
2
by: Kishan Hathiwala | last post by:
how do i make tracert command in .net without using 3rd party software?
2
by: Adrian | last post by:
Hi I need a VB dotnet ping and tracert GUI utility written in VB.net 2003 (not 2005). I was sure there would have been many working examples for ping but I cannot find any :( I was hoping to...
12
by: Pieter | last post by:
Hi, In my object oriented application (VB.NET 2.0, Windows Forms), a lot of objects are opened in different forms by a user. For instance (a stupid exemple, but it shows the easiest what's...
2
by: whitethomas12 | last post by:
Hi, I am kind of stuck on a project and I need some help with creating a VB.NET (Visual Studios 2008) application to do traceroute. I have looked all over the web and I cannot find anything...
1
by: Gabriel Genellina | last post by:
En Tue, 30 Sep 2008 03:53:21 -0300, cindy jones <mailcindy@gmail.com> escribió: Use the subprocess module: import subprocess host = 'www.microsoft.com' p = subprocess.Popen(,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.