Jump to content

Recommended Posts

Posted

I assume you are from Thailand (based on your username).

You want to get a list of disabled local user accounts?

You want to delete this disabled accounts?

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

 

Posted

I assume you are from Thailand (based on your username).

You want to get a list of disabled local user accounts?

You want to delete this disabled accounts?

I assume you are from Thailand (based on your username)....Yes!

You want to get a list of disabled local user accounts?...Yes!

You want to delete this disabled accounts?...Yes!

:sweating:

Posted (edited)

Try with ControlHide

and ControlCommand with IsEnabled

_WinAPI_EnumChildWindows to enumerate the Child Controls -

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted

Sorry PhoenixXL,

but are you sure you posted in the correct thread?

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

 

Posted

If you search the forum you will find a lot of threads describing how to create a local user (). Modifying them to delete the user should be easy.

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

 

Posted

but are you sure you posted in the correct thread?

My Misunderstanding. Sorry o:)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted

No problem.

I think the OPs problem can be solved using the WinNT provider.

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

 

Posted

Func Dis($UserName)
$strComputer = @ComputerName
$objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName)
if not @error Then
  $objUser.AccountDisabled = True
  $objUser.SetInfo
  ConsoleWrite("1")
Else
  ConsoleWrite("2")
  Exit
EndIf
EndFunc
Func Dele($UserName)
$strComputer = @ComputerName
$objUser = ObjGet("WinNT://" & $strComputer)
if not @error Then
  $objUser.Delete("user", $UserName)
  ConsoleWrite("1")
Else
  ConsoleWrite("2")
  Exit
EndIf
EndFunc

True or False o:)

Posted (edited)

Doesn't look bad! Couldn't test it but it looks good!

I would return a value for the calling function to check for success or error. In case of an error set macro @error.

Example:

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Func Dis($UserName)
    $strComputer = @ComputerName
    $objUser = ObjGet("WinNT://" & $strComputer & "/" & $UserName)
    If @error then Return SetError(1, @error, 0) ; Sets the return value = 0, @error = 1 and @extended to the COM error code
    $objUser.AccountDisabled = True
    $objUser.SetInfo
    If @error then Return SetError(2, @error, 0) ; Sets the return value = 0, @error = 2 and @extended to the COM error code
    Return 1 ; Sets the return value = 1
EndFunc
Func Dele($UserName)
   $strComputer = @ComputerName
   $objUser = ObjGet("WinNT://" & $strComputer)
   If @error then Return SetError(1, @error, 0) ; Sets the return value = 0, @error = 1 and @extended to the COM error code
   $objUser.Delete("user", $UserName)
   If @error then Return SetError(2, @error, 0) ; Sets the return value = 0, @error = 2 and @extended to the COM error code
   Return 1 ; Sets the return value = 1
EndFunc

; User's COM error function. Will be called if COM error occurs
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 by water

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

 

Posted

Good question.

If running AutoIt 3.3.8.1 you need a COM error handler. With 3.3.9.x is is obsolete.

I will modify my post above.

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

 

Posted

Full Code

#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
ConsoleWrite("1")
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
ConsoleWrite("1")
Else
ConsoleWrite("2")
Exit
EndIf
Elseif $a = 3 Then
$strComputer = @ComputerName
$objUser = ObjGet("WinNT://" & $strComputer)
if not @error Then
$objUser.Delete("user", $UserName)
ConsoleWrite("1")
Else
ConsoleWrite("2")
Exit
EndIf
EndIf
FileWrite("log.txt",$a&" | "&$UserName&@CRLF)
EndIf
Exit
; User's COM error function. Will be called if COM error occurs
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

Test for cmd = ="

(ma.exe 1 maxtesttest)

Posted Image

Posted

Don't understand what's going on.

Does the script write those messages forever or does it crash at the end?

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

 

Posted

Edit to...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
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

Posted Image

: :'( :

Posted

You removed the COM error handler. So the script now crashes?

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

 

Posted (edited)

You removed the COM error handler. So the script now crashes?

If you put "COM error handler" It will endless error, like before this post. :ermm: Edited by maxthailand
Posted

Which version of AutoIt do you run?

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

 

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
×
×
  • Create New...