Simple Ping function VBScript

I was after a ping function that met the following constraints;

  • Didn’t use GetObject.
  • Didn’t display any command (cmd) prompt.
  • Didn’t use a temporary file.

Here is what I found;

Function ping(node)
    Set WshShell = CreateObject("WScript.Shell")
    ping = Not CBool(WshShell.Run("ping -n 1 " & node, 0, True))
End Function

I was looking at a way to timeout the above ping function after 1 second using threading, but this didn’t quite make it so simple. Whilst ping offers a timeout value if you ping an incorrect hostname it will hang for a little while.


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *