General discussion


Automation Tools

By m92 ·

Earlier this morning I downloaded the ping automation tool.
Though it could be very useful tool, it does not tell you anything other than if a IP address on a given network is being used.
With that in mind, I decided it would be more useful if the tool resolved IP to name, using tracert.exe. After making minor adjustments to the script, it now resolves IP to name within a given network over a maximum of one hop.

Below is a copy of the script edited



Please copy everything between the "***" lines to a text file then save the file as "Auto Tracert.vbs"

'This script was writen to launches a ping test and sends keys to automate the process,
'Edited by Munir Ahmed to Tracert then write the output to a file.

Dim FirstPrompt, ErrorMessage, FileSystem, NetworkNum, FirstNodeNum, LastNodeNum, Dummy
Dim DotTest, TheDate, TheTime, TheFile, NodeNum

FirstPrompt = "Please enter the first three octets of the IP addresses you want to test." & vbCrLf & vbCrLf &_
"Use the form 123.456.789." & vbCrLf & vbCrLf &_
"Be sure to include the . after the last number."
ErrorMessage = "Operation failed!" & vbCrLf & vbCrLf &_
"You didn't include the . after the last number." & vbCrLf & vbCrLf &_
"Please repeat the operation."
TheDate = Date
TheTime = Time
Const ForWriting = 2, ForAppending = 8

Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSystem = CreateObject("Scripting.FileSystemObject")

NetworkNum = InputBox(FirstPrompt,"tracert Automation Tool")
If NetworkNum = "" Then Wscript.Quit

DotTest = Right(NetworkNum,1)
If DotTest <> "." Then
Dummy = WshShell.Popup(ErrorMessage,0, "tracert Automation Tool",16)
FirstNodeNum = InputBox("Enter the first node number in the test range:","tracert Automation Tool")
If FirstNodeNum = "" Then Wscript.Quit
LastNodeNum = InputBox("Enter the last node number in the test range:","tracert Automation Tool")
If LastNodeNum = "" Then Wscript.Quit
End If

Dummy = WshShell.Popup ( "Building tracert File. Please Wait...",1,"tracert Automation Tool",64)

If (FileSystem.FileExists("c:\tracertfile.txt")) Then
Set TheFile = FileSystem.OpenTextFile("c:\tracertfile.txt", ForAppending, True)
Set TheFile = FileSystem.OpenTextFile("c:\tracertfile.txt", ForWriting, True)
End If

TheFile.WriteLine(" tracert Automation Tool")
TheFile.WriteLine("This tracert Session was run on: " & TheDate & " at " & TheTime)
TheFile.WriteLine("Testing " & NetworkNum&FirstNodeNum & " thru " & NetworkNum&LastNodeNum)

For NodeNum = FirstNodeNum To LastNodeNum
WshShell.Run "Cmd.exe /c tracert.exe -h 1 " &NetworkNum&NodeNum &" >> c:\tracertfile.txt", 2,True
WshShell.Run "Cmd.exe /c Echo. >> c:\tracertfile.txt", 2,True
WshShell.Run "Cmd.exe /c Echo ********************************** >> c:\tracertfile.txt", 2,True

WshShell.Run "Notepad.exe c:\tracertfile.txt", 1,True



This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Related Discussions

Related Forums