Link to home
Start Free TrialLog in
Avatar of hmcgeehan
hmcgeehan

asked on

VBSCRIPT - computer exists?

Hi

Anyone know how to check if a computer on my domain is up or down?

I tried doing this but it says success when the drive p: doesnt exist!

dim WSHNetwork, WSHShell
Dim FileSysObj

set WSHShell=Wscript.CreateObject("Wscript.Shell")
Set WSHNetwork=Wscript.CreateObject("Wscript.Network")

ON ERROR RESUME Next
share = "\\pc024"
Drive = "p:"
If FileSysObj.DriveExists(share)=True Then
  if FileSysObj.DriveExists(Drive)=True Then
    'WSHNetwork.RemoveNetworkDrive Drive
    MsgBox "Success!" & share & "\" & drive & " does exist"
  else
    MsgBox "Error!" & share & "\" & drive & " does not exist"
  end If
end If
Avatar of YZlat
YZlat
Flag of United States of America image

try

Drive = "p"
then

if FileSysObj.DriveExists(Drive) Then
    'WSHNetwork.RemoveNetworkDrive Drive
    MsgBox "Success!" & share & "\" & drive & " does exist"
  else
    MsgBox "Error!" & share & "\" & drive & " does not exist"
  end If
ASKER CERTIFIED SOLUTION
Avatar of itdrms
itdrms
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TiwariVikas
TiwariVikas

Hi itdrms,

Great code !! I don't know whether the above code is useful in this particular question or not... but in general this is a very useful piece of code for me !!

Thanks a lot !!

Cheers,
VIkas.
well, since your asking, I'd appreciate getting the points.  I tested my script against the 3 possibilites of server state and the script worked properly to determine if a computer is up or down.  Thx