PsaltyDS Posted March 22, 2006 Author Share Posted March 22, 2006 I would change the Error handler that it doesn't show a msgbox in case of errors to enable you to run it in batch..: ; Custom COM object error handler Func ComErrFunc() Local $HexNumber = Hex($oMyError.number, 8) ConsoleWrite("COM Error! Number is: " & $HexNumber & "Linenbr is: " & $oMyError.scriptline & _ "Description is: " & $oMyError.description & "Windescription is: " & $oMyError.windescription) SetError(1); something to check for when this function returns EndFunc;==>ComErrFunc No reason really.. this is the same.. I am soooo close! I'm now getting compile errors: C:\PROGRA~1\AutoIt3\beta\Include\Test\_Test.au3(49,42) : WARNING: $oComError: possibly used before declaration. Local $HexNumber = Hex($oComError.number, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ I changed the name to $oComError only to see if it changed the error report, it was the same with $oMyError. The two functions _Add_Local_User() and ComErrFunc() are in an include file called _Test.au3. I get the error when compiling the script that includes this file. I tried making the $oComError global by: Global $oComError = ObjEvent("AutoIt.Error", "ComErrFunc"); Install a custom error handler But it didn't fix it??? 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 More sharing options...
Developers Jos Posted March 22, 2006 Developers Share Posted March 22, 2006 I am soooo close! I'm now getting compile errors: C:\PROGRA~1\AutoIt3\beta\Include\Test\_Test.au3(49,42) : WARNING: $oComError: possibly used before declaration. Local $HexNumber = Hex($oComError.number, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ I changed the name to $oComError only to see if it changed the error report, it was the same with $oMyError. The two functions _Add_Local_User() and ComErrFunc() are in an include file called _Test.au3. I get the error when compiling the script that includes this file. I tried making the $oComError global by: Global $oComError = ObjEvent("AutoIt.Error", "ComErrFunc"); Install a custom error handler But it didn't fix it??? It is a Warning, not Error. The reason is that $oComError is declared in a Function and Au3check cannot determine if it always be executed before ComErrFunc is ran. It might be a better option anyways to move the :Global $oComError = ObjEvent("AutoIt.Error", "ComErrFunc"); Install a custom error handler to the top of your program and not run it everytime you add an user.... 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 More sharing options...
PsaltyDS Posted March 22, 2006 Author Share Posted March 22, 2006 It is a Warning, not Error. The reason is that $oComError is declared in a Function and Au3check cannot determine if it always be executed before ComErrFunc is ran. It might be a better option anyways to move the :Global $oComError = ObjEvent("AutoIt.Error", "ComErrFunc"); Install a custom error handler to the top of your program and not run it everytime you add an user.... Wound up with the following in the main script file: ; Declare COM Object error handler: Global $oComError = ObjEvent("AutoIt.Error", "_ComErrFunc"); Install a custom error handler ; Function _ComErrFunc() ; Custom COM object error handler Func _ComErrFunc() Local $HexNumber = Hex($oComError.number, 8) ConsoleWrite("COM Error! Number is: " & $HexNumber & "Linenbr is: " & $oComError.scriptline & _ "Description is: " & $oComError.description & "Windescription is: " & $oComError.windescription) SetError(1); something to check for when this function returns EndFunc ;==>_ComErrFunc An the following in the include file (along with a bunch of other user management functions): ; ======================================================== ; _Add_LocalUser function ; ======================================================== ; Call with: _Add_LocalUser($sNewUsrName, $sNewUsrPass [, $sNewUsrFull] [, $sNewUsrDesc]) where: ; $sNewUsrName = UserName to add ; $sNewUsrPass = New user's password ; $sNewUsrFull = (optional) User's full name ; $sNewUsrDesc = (optional) User's description (comment) ; Returns 1 for success, 0 for fail Func _Add_LocalUser($sNewUsrName, $sNewUsrPass, $sNewUsrFull = "", $sNewUsrDesc = "") ; Init COM object $colAccounts = ObjGet("WinNT://" & @ComputerName & "") ; Create user $objUser = $colAccounts.Create ("user", $sNewUsrName) $objUser.SetPassword ($sNewUsrPass) $objUser.Put ("Fullname", $sNewUsrFull) $objUser.Put ("Description", $sNewUsrDesc) $objUser.SetInfo If @error Then Return 0 Else Return 1 EndIf EndFunc ;==>_Add_LocalUser Moving the declaration of $oComError and the ComErrFunc() to the main script removed all errors and warnings, and it works great! Complex passwords for everybody! WooHoo!!! 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 More sharing options...
JSThePatriot Posted April 10, 2006 Share Posted April 10, 2006 Thanks to all who contributed to this post. I have found this script most useful. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now