maxthailand Posted April 7, 2013 Posted April 7, 2013 How disabled windows username?and how delete windows username?form link ==> #windows server 2003
water Posted April 7, 2013 Posted April 7, 2013 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
maxthailand Posted April 7, 2013 Author Posted April 7, 2013 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!
PhoenixXL Posted April 7, 2013 Posted April 7, 2013 (edited) Try with ControlHideand ControlCommand with IsEnabled_WinAPI_EnumChildWindows to enumerate the Child Controls - Edited April 7, 2013 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.
water Posted April 7, 2013 Posted April 7, 2013 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
maxthailand Posted April 7, 2013 Author Posted April 7, 2013 Try with ControlHideand ControlCommand with IsEnabled_WinAPI_EnumChildWindows to enumerate the Child Controls - Example
water Posted April 7, 2013 Posted April 7, 2013 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
PhoenixXL Posted April 7, 2013 Posted April 7, 2013 but are you sure you posted in the correct thread?My Misunderstanding. Sorry 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.
water Posted April 7, 2013 Posted April 7, 2013 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
maxthailand Posted April 7, 2013 Author Posted April 7, 2013 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
water Posted April 7, 2013 Posted April 7, 2013 (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 April 7, 2013 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
JohnOne Posted April 7, 2013 Posted April 7, 2013 Do object methods or/and properties set @error? for instance $objUser.AccountDisabled = True and $objUser.Delete("user", $UserName) or is an error handler needed. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
water Posted April 7, 2013 Posted April 7, 2013 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
maxthailand Posted April 9, 2013 Author Posted April 9, 2013 Full Codeexpandcollapse 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 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 ;==>_ErrFuncTest for cmd = ="(ma.exe 1 maxtesttest)
water Posted April 9, 2013 Posted April 9, 2013 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
maxthailand Posted April 10, 2013 Author Posted April 10, 2013 Edit to...expandcollapse popup#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 :'(
water Posted April 10, 2013 Posted April 10, 2013 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
maxthailand Posted April 10, 2013 Author Posted April 10, 2013 (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. Edited April 10, 2013 by maxthailand
water Posted April 10, 2013 Posted April 10, 2013 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
maxthailand Posted April 10, 2013 Author Posted April 10, 2013 Which version of AutoIt do you run?v3.3.6.1
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