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!

Testing Server Availibility 1

Status
Not open for further replies.

murraykr

Technical User
Oct 19, 2001
19
US
I am writing a script to run thru a list of mapped network drives in a user profile to determine if each network share still exists. If the share no longer exists, I am disconnecting the mapped drive. If the server is down, then my script assumes that the share no longer exists and disconnects the drive. Not the behaviour I want.
Can someone please give me a hint on how I can test to see if a server is up using vbscript please. I do not have administrator access to every server this script may reference, so I cannot drop a file or share on each one to test for existence.
Thanks.
 
You could try to ping the server

hostname = ipaddress

if not reachable(hostname) then
(server is down)
else
(server is not down)
end if

Function Reachable(Hostname)
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.EXEC("ping -n 2 -w 500 " & hostname)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Do While oExec.StdOut.AtEndOfStream <> True
retstring = oExec.StdOut.ReadLine
' wscript.echo retstring
if instr(retString, &quot;Reply&quot;)>0 then
reachable = true
exit do
end if
Loop
end function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top