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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW CAN I CHECK IF GET OBJECT SUCCED 1

Status
Not open for further replies.

vivis

IS-IT--Management
Oct 1, 2002
17
MX
HI, I DID A SCRIPT THAT GET FREESPACES OF A LOT OF MACHINES THE SCRIPT RUN AS A SERVICE ONCE EVERYDAY, THE PROBLEM IS THAT WHEN A SERVER IS NOT AVAILABLE THE SCRIPT STOPS FOR A WHILE THEN CONTINUE BUT I NEED THAT IF THE SERVER IS NOT AVAILABLE THEN SKIP IT AND CONTINUE WITH NEXT SERVER, IM USING WMI GETOBJECT, SO IS THERE A WAY TO KNOW IF THE CONECTION WITH THE SERVER FAIL? THANX A LOT!!!!
 
If you want to trap the error set On Error Resume Next somewhere before the WMI call. After the call check the ERR number. If it's 0 it was successful. If it is greater or less than 0 there was an error.

Typically what I will use is the following code. It doesn't stall for as long as the WMI calls if a computer isn't there.

On Error Resume Next
Set comp = GetObject(&quot;WinNT://<domain>/&quot; & CompName)
If Err <> 0 Then
'Write a text file or net send or something
Err = 0
else
'Make your WMI call
End if

Dana Hallenbeck
 
Nice :) --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
This space has nothing in it, it's all ni your imagination
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top