Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS Ping Help Needed

Status
Not open for further replies.

car94401

IS-IT--Management
Mar 1, 2010
3
CA
I am new to vbs and cannot seem to get a script together after multiple attempts. I need to ping a server name and have the results say server DNS name such as abcd1234 is not responding and ping the same machine by IP and say IP address is not responding. Any assistance is appreciated. I am lost. Carroll.

The case would be something like
If ping staus (DNS) =0 then echo DNS is OK
else ping status (IP) =0 then echo DNS bad, IP OK
else echo cannot reach server
endif

strMachines = "abcd1234;112.12.131.123"
aMachines = split(strMachines, ";")

For Each machine in aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
WScript.Echo("Computer " & machine & " is not reachable")
End If
Next
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top