Jump to content

Windows disabled username


Recommended Posts

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

#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

Posted Image

Link to comment
Share on other sites

Can you run this script uncompiled so we can see the line number?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Posted Image

#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

:unsure:

Edited by maxthailand
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Code

#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 by maxthailand
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

I think you need to modify

$objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName)
to
$objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName & ",user")

Error line 19 :

Posted Image

Full code

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

×
×
  • Create New...