Jump to content

Error Checking


Ghost21
 Share

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!!!

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...