Login | |
|
 |
Re: Pinging script that prompts for address range. - 2/6/2005 1:52:00 AM
|
|
 |
|
| |
johnny_boy
Posts: 1
Score: 0
Joined: 2/6/2005
From:
Status: offline
|
Here's my script that prompts for start and end IP address, pings the range, performst and nbtstat -A on devices that reply and creates 4 text .log files of the results in C:\ with filenames that starts with Ping '******************************************************************************* ' ' Ping IP Range v1.0 ' ' (c) 2005 Jonathan Wallace ' '******************************************************************************* '******************************************************************************* ' ' Main Program ' '******************************************************************************* On Error Resume Next '------------------------------------------------------------------------------- ' Declare Constants '------------------------------------------------------------------------------- Const FOR_WRITING = 2 Const LOG_FILE_PATH = "C:\" Const ECHOES = 4 '------------------------------------------------------------------------------- ' Set Global Variable Values '------------------------------------------------------------------------------- strPingAllLogFilePath = LOG_FILE_PATH & "Ping All Output.log" strPingReplyLogFilePath = LOG_FILE_PATH & "Ping Reply.log" strPingNoReplyLogFilePath = LOG_FILE_PATH & "Ping No Reply.log" strPingPartialLossLogFilePath = LOG_FILE_PATH & "Ping Partial Packet Loss.log" '------------------------------------------------------------------------------- ' Get Start of Range IP address '------------------------------------------------------------------------------- strIPStart = " " bValid = False While (bValid = False) AND (strIPStart <> "") strIPStart = InputBox("Enter Start of Range IP address:", "Ping IP Range") 'Remove leading and trailing spaces strIPStart = Trim(strIPStart) 'Test that entry is a valid IP address bValid = ValidIP(strIPStart) If (bValid = False) AND (strIPStart <> "") Then MsgBox strIPStart & " is not a valid IP address", vbCritical, "Ping IP Range" WEnd '------------------------------------------------------------------------------- ' Get End of Range IP address '------------------------------------------------------------------------------- strIPEnd = " " bValid = False While (bValid = False) AND (strIPStart <> "") AND (strIPEnd <> "") strIPEnd = InputBox("Start of Range: " & strIPStart & VBLF & VBLF & "Enter End of Range IP address:", "Ping IP Range", strIPStart) 'Remove leading and trailing spaces strIPEnd = Trim(strIPEnd) 'Test that entry is a valid IP address bValid = ValidIP(strIPEnd) If (bValid = False) AND (strIPEnd <> "") Then MsgBox strIPEnd & " is not a valid IP address", vbCritical, "Ping IP Range" ElseIf (iIPEnd < iIPStart) AND (strIPEnd <> "") Then MsgBox strIPEnd & " is before the Start of Range: " & strIPStart, vbCritical, "Ping IP Range" bValid = False End If WEnd '------------------------------------------------------------------------------- ' Get Number of Ping Echoes to Send '------------------------------------------------------------------------------- strEchoes = " " bValid = False While (bValid = False) AND (strIPStart <> "") AND (strIPEnd <> "") AND (strEchoes <> "") strEchoes = InputBox("Enter Number of Ping Echoes to Send:", "Ping IP Range", ECHOES) 'Remove leading and trailing spaces strEchoes = Trim(strEchoes) 'Test that entry is a Number bValid = ValidNumber(strEchoes) If (bValid = False) AND (strEchoes <> "") Then MsgBox strEchoes & " is not a valid number", vbCritical, "Ping IP Range" WEnd '------------------------------------------------------------------------------- ' Ping Range '------------------------------------------------------------------------------- 'If User did not Cancel If (strIPStart <> "") AND (strIPEnd <> "") AND (strEchoes <> "") Then Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") 'Create Log Files Set objPingAllLogFile = objFSO.CreateTextFile(strPingAllLogFilePath, False) Set objPingReplyLogFile = objFSO.CreateTextFile(strPingReplyLogFilePath, False) Set objPingNoReplyLogFile = objFSO.CreateTextFile(strPingNoReplyLogFilePath, False) Set objPingPartialLossLogFile = objFSO.CreateTextFile(strPingPartialLossLogFilePath, False) 'Open Log Files for OverWriting Set objPingAllLogFile = objFSO.OpenTextFile(strPingAllLogFilePath, FOR_WRITING) Set objPingReplyLogFile = objFSO.OpenTextFile(strPingReplyLogFilePath, FOR_WRITING) Set objPingNoReplyLogFile = objFSO.OpenTextFile(strPingNoReplyLogFilePath, FOR_WRITING) Set objPingPartialLossLogFile = objFSO.OpenTextFile(strPingPartialLossLogFilePath, FOR_WRITING) 'Write Start of Log Files objPingAllLogFile.WriteLine Date & " " & Time & vbTab & "Ping IP Range: " & strIPStart & " to " & strIPEnd & vbTab & "All Output Log"
|
|
| |
|
|
|
|
|