I am looking to automate a process where I can run through a list of devices, ping them, and learn if they are up (meaning they are communicating) or down (no successful ping). I have looked at some tutorials and plans and have made it to the following script.
I may be getting confused between the shell
function and what I have below. I understood it to be that in my ret
value returns as 0, the ping was a fail. But rather, I think I am wrong on that. Can anybody offer me clarity on this issue of the function and how to work with return values. Better yet, has anyone ever tried to create something similar to what I am doing?
Sub testPing()
Dim WshShell
Set WshShell = VBA.CreateObject("WScript.Shell")
Dim testIP As String
Dim testPort As String
Dim yes, no As String
yes = "true"
no = "false"
testIP = Cells(3, 2).Value
testPort = Cells(3, 3).Value
ret = WshShell.Run("C:\Users\John.Doe\paping.exe " & testIP & " -p " & testPort & " -c 3", 0, True)
Debug.Print ret
End Sub