usetheforce2
06-16-2003, 09:18 PM
hello all,
For all you scripters out there, heres a activex dll you can use to enable you scripts to easilly perform single, multiple, and subnet pinging. download the following ActiveX dll project and compile it.
NOTE: if for some reason you haven't the ability to compile the project, download the "already-compiled" .dll and register it using the regsvr32 utility.
regsvr32 <dllpath>\Netw.dll
dllpath being the path to the location of the dll
Let me describe some of the key functions and methods provided by the activex dll that are important to know of:
First and most importantly is the Ping method which returns True for a successful ping and False for a failed ping attempt. This method only requires one parameter - a dotted decimal ip address. This is all that is required to ping a remote host. However, it would be nice to know some more tidbits of info, such as the time it took, and the status of the ping. So, you can use the RoundTripTime and PingStatusMsg properties to establish further information of the ping. The following basic script will ping a remote host, and depending on the success or failiure of the ping attempt, display some info.
Sample VBScript (.vbs)
' First instatiate an ICMP_Ping object
Set ipPing = CreateObject("NetW.ICMP_Ping")
' host to ping
IPAddress = "24.100.3.40"
' how many times to ping each host
numTimes = 2
' of times to ping each host
For y = 1 To numTimes
' if ping is successful then display some simple properties
If ipPing.Ping(cstr(IPAddress)) Then
PingStatus = PingStatus & _
IPAddress & " " & _
ipPing.RoundTripTime & "ms" & vbNewLine
Else
' if fail, display the message
PingStatus = PingStatus & _
IPAddress & " " & _
ipPing.PingStatusMsg & vbNewLine
End If
wscript.echo PingStatus
Next
run this script by either double clicking or command line
cscript <scriptpath>\simpleping.vbs
For all you scripters out there, heres a activex dll you can use to enable you scripts to easilly perform single, multiple, and subnet pinging. download the following ActiveX dll project and compile it.
NOTE: if for some reason you haven't the ability to compile the project, download the "already-compiled" .dll and register it using the regsvr32 utility.
regsvr32 <dllpath>\Netw.dll
dllpath being the path to the location of the dll
Let me describe some of the key functions and methods provided by the activex dll that are important to know of:
First and most importantly is the Ping method which returns True for a successful ping and False for a failed ping attempt. This method only requires one parameter - a dotted decimal ip address. This is all that is required to ping a remote host. However, it would be nice to know some more tidbits of info, such as the time it took, and the status of the ping. So, you can use the RoundTripTime and PingStatusMsg properties to establish further information of the ping. The following basic script will ping a remote host, and depending on the success or failiure of the ping attempt, display some info.
Sample VBScript (.vbs)
' First instatiate an ICMP_Ping object
Set ipPing = CreateObject("NetW.ICMP_Ping")
' host to ping
IPAddress = "24.100.3.40"
' how many times to ping each host
numTimes = 2
' of times to ping each host
For y = 1 To numTimes
' if ping is successful then display some simple properties
If ipPing.Ping(cstr(IPAddress)) Then
PingStatus = PingStatus & _
IPAddress & " " & _
ipPing.RoundTripTime & "ms" & vbNewLine
Else
' if fail, display the message
PingStatus = PingStatus & _
IPAddress & " " & _
ipPing.PingStatusMsg & vbNewLine
End If
wscript.echo PingStatus
Next
run this script by either double clicking or command line
cscript <scriptpath>\simpleping.vbs