Jump to content
Sign in to follow this  
Ghost21

Error Checking

Recommended Posts

Having trouble when I try to pull an IP address from a computer on the network and it can't get it the program just crashes with this error...

$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

$colItems = $objWMIService^ ERROR

I'm really bad at error checking can someone give me an example that works to learn from...

My error checking right now consists of If @error then Continueloop which ain't working to S*** hot for me...

HELP!!!

Share this post


Link to post
Share on other sites

Add an COM errorhandler as described in the Helpfile to avoid the script from stopping to run..

Share this post


Link to post
Share on other sites

Having trouble when I try to pull an IP address from a computer on the network and it can't get it the program just crashes with this error...

$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

$colItems = $objWMIService^ ERROR

I'm really bad at error checking can someone give me an example that works to learn from...

My error checking right now consists of If @error then Continueloop which ain't working to S*** hot for me...

HELP!!!

Probably means your $objWMIService = ObjGet(...etc.) failed. Test it with:

If Not IsObj($objWMIService) Then 
      MsgBox(16, "Error", "Failed to get WMI object")
      Exit
EndIf

^_^

P.S. ...or you could just add a COM error handler like Jos said -- If you want to go with the boring, correct way... :)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...