There is a known issue at the moment with the DesktopX System.Ping() command. Do not attempt to use this as it will crash DesktopX.
I am providing some code that can be used within your script as a workaround. If you prefer to download this, the article link will bring you to an object I have just uploaded. Note that WMI will need to be available on the system on which this is run.
Feel free to copy the following code into your script and use freely. The syntax is completely identical to the System.Ping command, minus the call to the System namespace. Invoke this like so:
MsgBox "Ping response: " & Ping("www.stardock.com")
The WMI Ping function:
Code: vbscript
- Function Ping(strIP)
- Dim objWMI
- On Error Resume Next
- Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
- If objWMI Is nothing Then
- Ping = "Error: WMI Unavailable"
- Exit Function
- End If
- Dim objPingStatus
- For Each objPingStatus In objWMI.ExecQuery("Select * From Win32_PingStatus Where Address = '" & strIP & "'")
- If IsNull(objPingStatus.StatusCode) Or objPingStatus.Statuscode<>0 Then
- Ping = "Error in Ping query"
- Else
- Ping = objPingStatus.ResponseTime
- End If
- Next
- End Function
Thank you RomanDA for the heads up!