water Posted April 10, 2013 Posted April 10, 2013 Can you update to the latest version 3.3.8.1? According to the history a lot of COM errors have been resolved. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
maxthailand Posted April 10, 2013 Author Posted April 10, 2013 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") if $CmdLine[0] <> 2 Then ConsoleWrite("0") Exit Else $a = $CmdLine[1] $UserName = $CmdLine[2] if $a ==1 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objUser.AccountDisabled = True $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == True Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 2 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objUser.AccountDisabled = False $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == False Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 3 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer) if not @error Then $objUser.Delete("user", $UserName) $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if @error Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Exit Else ConsoleWrite("2") Exit EndIf EndIf FileWrite("log.txt",$a&" | "&$UserName&@CRLF) EndIf Exit Func _ErrFunc($oError) ; Do anything here. ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
water Posted April 10, 2013 Posted April 10, 2013 Can you run this script uncompiled so we can see the line number? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
maxthailand Posted April 11, 2013 Author Posted April 11, 2013 (edited) expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") if $CmdLine[0] <> 2 Then ConsoleWrite("0") Exit Else $a = $CmdLine[1] $UserName = $CmdLine[2] if $a ==1 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objUser.AccountDisabled = True $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == True Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 2 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objUser.AccountDisabled = False $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == False Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 3 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer) if not @error Then $objUser.Delete("user", $UserName) $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if @error Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Exit Else ConsoleWrite("2") Exit EndIf EndIf FileWrite("log.txt",$a&" | "&$UserName&@CRLF) EndIf Exit Func _ErrFunc($oError) ; Do anything here. ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Edited April 11, 2013 by maxthailand
water Posted April 11, 2013 Posted April 11, 2013 You compiled the script and then ran the exe. That's why "scriptline" is returned as -1 by the COM error handler. if you press F5 in SciTe you get the line number in error. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
maxthailand Posted April 11, 2013 Author Posted April 11, 2013 (edited) Code expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") #cs if $CmdLine[0] <> 2 Then ConsoleWrite("0") Exit Else $a = $CmdLine[1] $UserName = $CmdLine[2] #ce $a = 1 $UserName = "test" if $a = 1 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objUser.AccountDisabled = True $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == True Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 2 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objUser.AccountDisabled = False $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == False Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 3 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer) if not @error Then $objUser.Delete("user", $UserName) $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if @error Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Exit Else ConsoleWrite("2") Exit EndIf EndIf FileWrite("log.txt",$a&" | "&$UserName&@CRLF) ;~ EndIf Exit Func _ErrFunc($oError) ; Do anything here. ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Error show err.number is: -2147352567 err.windescription: Unspecified error err.description is: Unspecified error err.source is: Active Directory err.helpfile is: err.helpcontext is: 0 err.lastdllerror is: 0 err.scriptline is: 19 err.retcode is: -2147467259 err.number is: -2147352567 err.windescription: err.description is: The directory property cannot be found in the cache. err.source is: Active Directory err.helpfile is: err.helpcontext is: 0 err.lastdllerror is: 0 err.scriptline is: 23 err.retcode is: -2147463155 2+>18:51:36 AutoIT3.exe ended.rc:0 >_< Edited April 11, 2013 by maxthailand
water Posted April 11, 2013 Posted April 11, 2013 I think you need to modify$objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName)to$objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName & ",user") My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
maxthailand Posted April 11, 2013 Author Posted April 11, 2013 I think you need to modify$objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName)to$objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName & ",user") Error line 19 Full code expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") #cs if $CmdLine[0] <> 2 Then ConsoleWrite("0") Exit Else $a = $CmdLine[1] $UserName = $CmdLine[2] #ce $a = 1 $UserName = "test" if $a = 1 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName& ",user") if not @error Then $objUser.AccountDisabled = True $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName& ",user") if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == True Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 2 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName& ",user") if not @error Then $objUser.AccountDisabled = False $objUser.SetInfo $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName& ",user") if not @error Then $objAccountDisabled = $objUser.Get("AccountDisabled") if $objAccountDisabled == False Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Else ConsoleWrite("3") EndIf Exit Else ConsoleWrite("2") Exit EndIf Elseif $a = 3 Then $strComputer = @ComputerName $objUser = ObjGet("WinNT://" & $strComputer) if not @error Then $objUser.Delete("user", $UserName) $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName) if @error Then ConsoleWrite("1") Else ConsoleWrite("2") EndIf Exit Else ConsoleWrite("2") Exit EndIf EndIf FileWrite("log.txt",$a&" | "&$UserName&@CRLF) ;~ EndIf Exit Func _ErrFunc($oError) ; Do anything here. ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
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