Ping a host and get true or false returned
- Options: strHost = Hostname
strHost = InputBox ("Host to Ping") msgBox funPing(strHost) Function funPing(strHost) ' Function: funPing , Pings a host and returns true on success or false if failed ' Option: Hostname or IP-Address ' Author: 2006-01-19 50beans.com Dim objPing, objPingStatus Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & strHost & "'") For Each objPingStatus in objPing If IsNull(objPingStatus.StatusCode) or objPingStatus.StatusCode <> 0 Then funPing = false Else funPing = true End If Next set objPingStatus = Nothing Set objPing = Nothing End Function |