473,734 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) 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
.WorkingDirecto ry = "C:\windows\sys tem32"
.FileName = ExeFileName
.Arguments = Arguments
.UseShellExecut e = False
.RedirectStanda rdError = True
.RedirectStanda rdInput = True
.RedirectStanda rdOutput = True
.WindowStyle = ProcessWindowSt yle.Hidden
.CreateNoWindow = True
End With
Try
p.Start()
s = p.StandardOutpu t.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("1 92.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("1 92.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("t imed out")
lblStatus.Text = "STATUS: Link is Down"
If r 0 Then
sever = 3
devicname = "NetworkDow n"
alrstr = "The Network is Down
SqlSelectInsert (sever, devicname, alrstr)
End If
End If
End If
'MessageBox.Sho w(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.Sql Client.SqlConne ction
Dim sConnStr As String
sConnStr = "server=myserve r
\nmssse;uid=tes t;pwd=test12345 ;database=test_ Database"
sqlCon.Connecti onString = sConnStr
' Query the database before making and entry
sqlCon.Open()
Dim sqlcommand As New System.Data.Sql Client.SqlComma nd
sqlcommand.Comm andType = CommandType.Sto redProcedure
sqlcommand.Comm andText = "dbo.Select_Las tRouteEntry"
sqlcommand.Conn ection = sqlCon
Dim sqlDataReader As System.Data.Sql Client.SqlDataR eader
sqlDataReader = sqlcommand.Exec uteReader
If sqlDataReader.H asRows Then
While sqlDataReader.R ead
sqlResult =
sqlDataReader.G etString(sqlDat aReader.GetOrdi nal("devname"))
End While
End If
sqlCon.Close()
If Not devicname = sqlResult Then
sqlCon.Open()
Dim sqlCommand2 As New System.Data.Sql Client.SqlComma nd
sqlCommand2.Com mandType = CommandType.Sto redProcedure
sqlCommand2.Com mandText = "dbo.Insert_Rou te_Info"
sqlCommand2.Con nection = sqlCon
sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@sever", sever))
sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@devname" , devicname))
sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@alrstr", alrstr))
sqlCommand2.Exe cuteNonQuery()
sqlCon.Close()
End If
Return True
End Function
Thank you in advance
Apr 5 '08 #1
2 2026
On Apr 4, 5:54*pm, whitethoma...@g mail.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.EventArg s) 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
* * * * * * .WorkingDirecto ry = "C:\windows\sys tem32"
* * * * * * .FileName = ExeFileName
* * * * * * .Arguments = Arguments
* * * * * * .UseShellExecut e = False
* * * * * * .RedirectStanda rdError = True
* * * * * * .RedirectStanda rdInput = True
* * * * * * .RedirectStanda rdOutput = True
* * * * * * .WindowStyle = ProcessWindowSt yle.Hidden
* * * * * * .CreateNoWindow = True
* * * * End With
* * * * Try
* * * * * * p.Start()
* * * * * * s = p.StandardOutpu t.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("1 92.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("1 92.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("t imed out")
* * * * * * * * lblStatus.Text = "STATUS: Link is Down"
* * * * * * * * If r 0 Then
* * * * * * * * * * sever = 3
* * * * * * * * * * devicname = "NetworkDow n"
* * * * * * * * * * alrstr = "The Network is Down
* * * * * * * * * * SqlSelectInsert (sever, devicname, alrstr)
* * * * * * * * End If
* * * * * * End If
* * * * End If
* * * * 'MessageBox.Sho w(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.Sql Client.SqlConne ction
* * * * Dim sConnStr As String
* * * * sConnStr = "server=myserve r
\nmssse;uid=tes t;pwd=test12345 ;database=test_ Database"
* * * * sqlCon.Connecti onString = sConnStr
* * * * ' Query the database before making and entry
* * * * sqlCon.Open()
* * * * Dim sqlcommand As New System.Data.Sql Client.SqlComma nd
* * * * sqlcommand.Comm andType = CommandType.Sto redProcedure
* * * * sqlcommand.Comm andText = "dbo.Select_Las tRouteEntry"
* * * * sqlcommand.Conn ection = sqlCon
* * * * Dim sqlDataReader As System.Data.Sql Client.SqlDataR eader
* * * * sqlDataReader = sqlcommand.Exec uteReader
* * * * If sqlDataReader.H asRows Then
* * * * * * While sqlDataReader.R ead
* * * * * * * * sqlResult =
sqlDataReader.G etString(sqlDat aReader.GetOrdi nal("devname"))
* * * * * * End While
* * * * End If
* * * * sqlCon.Close()
* * * * If Not devicname = sqlResult Then
* * * * * * sqlCon.Open()
* * * * * * Dim sqlCommand2 As New System.Data.Sql Client.SqlComma nd
* * * * * * sqlCommand2.Com mandType = CommandType.Sto redProcedure
* * * * * * sqlCommand2.Com mandText = "dbo.Insert_Rou te_Info"
* * * * * * sqlCommand2.Con nection = sqlCon
* * * * * * sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@sever", sever))
* * * * * * sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@devname" , devicname))
* * * * * * sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@alrstr", alrstr))
* * * * * * sqlCommand2.Exe cuteNonQuery()
* * * * * * 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...@g mail.com wrote:
On Apr 4, 5:54*pm, whitethoma...@g mail.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.EventArg s) 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
* * * * * * .WorkingDirecto ry = "C:\windows\sys tem32"
* * * * * * .FileName = ExeFileName
* * * * * * .Arguments = Arguments
* * * * * * .UseShellExecut e = False
* * * * * * .RedirectStanda rdError = True
* * * * * * .RedirectStanda rdInput = True
* * * * * * .RedirectStanda rdOutput = True
* * * * * * .WindowStyle = ProcessWindowSt yle.Hidden
* * * * * * .CreateNoWindow = True
* * * * End With
* * * * Try
* * * * * * p.Start()
* * * * * * s = p.StandardOutpu t.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("1 92.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("1 92.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("t imed out")
* * * * * * * * lblStatus.Text = "STATUS: Link is Down"
* * * * * * * * If r 0 Then
* * * * * * * * * * sever = 3
* * * * * * * * * * devicname = "NetworkDow n"
* * * * * * * * * * alrstr = "The Network is Down
* * * * * * * * * * SqlSelectInsert (sever, devicname, alrstr)
* * * * * * * * End If
* * * * * * End If
* * * * End If
* * * * 'MessageBox.Sho w(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.Sql Client.SqlConne ction
* * * * Dim sConnStr As String
* * * * sConnStr = "server=myserve r
\nmssse;uid=tes t;pwd=test12345 ;database=test_ Database"
* * * * sqlCon.Connecti onString = sConnStr
* * * * ' Query the database before making and entry
* * * * sqlCon.Open()
* * * * Dim sqlcommand As New System.Data.Sql Client.SqlComma nd
* * * * sqlcommand.Comm andType = CommandType.Sto redProcedure
* * * * sqlcommand.Comm andText = "dbo.Select_Las tRouteEntry"
* * * * sqlcommand.Conn ection = sqlCon
* * * * Dim sqlDataReader As System.Data.Sql Client.SqlDataR eader
* * * * sqlDataReader = sqlcommand.Exec uteReader
* * * * If sqlDataReader.H asRows Then
* * * * * * While sqlDataReader.R ead
* * * * * * * * sqlResult =
sqlDataReader.G etString(sqlDat aReader.GetOrdi nal("devname"))
* * * * * * End While
* * * * End If
* * * * sqlCon.Close()
* * * * If Not devicname = sqlResult Then
* * * * * * sqlCon.Open()
* * * * * * Dim sqlCommand2 As New System.Data.Sql Client.SqlComma nd
* * * * * * sqlCommand2.Com mandType = CommandType.Sto redProcedure
* * * * * * sqlCommand2.Com mandText = "dbo.Insert_Rou te_Info"
* * * * * * sqlCommand2.Con nection = sqlCon
* * * * * * sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@sever", sever))
* * * * * * sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@devname" , devicname))
* * * * * * sqlCommand2.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@alrstr", alrstr))
* * * * * * sqlCommand2.Exe cuteNonQuery()
* * * * * * 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
4811
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
2214
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? -- Thanks
4
12214
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 easiest way to do that? The idea is to enter the remote address or URL and call some method to get a full trace between two machines in the form like: 111.111.111;222.222.222;333.333.333 Is it already done by somebody or maybe we have some...
2
2134
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 for each session, so that three users can connect to three different databases. But I get crazy because: -With interop all users share one instance - pure chaos (the instance is
2
2353
by: Kishan Hathiwala | last post by:
how do i make tracert command in .net without using 3rd party software?
2
4065
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 find one I could just add to my app as there is no point in reinventing the wheel! I could live without the tracert, but I do need it to run from a windows form.
12
1083
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 happening): -two instances of the Company-Object: MyCompany1 and MyCompany2, both of them are poiting to the same Company: for isntance the Company Microsoft. The problem is: if the user makes changes to one of the 2 instances, these changes are...
2
3397
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 really useful. Can some one please post some sample code so I can view it. Once I have an I dea of how to do it then I can simply add it to the rest of my code.
1
4851
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(, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.