Jump to content
Sign in to follow this  
maxthailand

Windows disabled username

Recommended Posts

maxthailand

How disabled windows username?

and how delete windows username?

form link ==>

#windows server 2003

Posted Image

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
maxthailand

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:

Share this post


Link to post
Share on other sites
PhoenixXL

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.

Share this post


Link to post
Share on other sites
water

Sorry PhoenixXL,

but are you sure you posted in the correct thread?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
maxthailand

Try with ControlHide

and ControlCommand with IsEnabled

_WinAPI_EnumChildWindows to enumerate the Child Controls -

Example :rolleyes:

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
PhoenixXL

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.

Share this post


Link to post
Share on other sites
water

No problem.

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
maxthailand

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:)

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
maxthailand

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

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
maxthailand

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

: :'( :

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
maxthailand

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

Share this post


Link to post
Share on other sites
water

Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
maxthailand

Which version of AutoIt do you run?

v3.3.6.1 :sweating:

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • Iznogoud
      By Iznogoud
      Hi,
      Does anyone knows why this command doesn't work?
      Run(@ComSpec & " /c " & "devcon.exe hwids * | findstr /R ""1050&PID_0114&REV_0340&MI_01"" || (rundll32.exe user32.dll, LockWorkStation)", "", "") This is the command in commandline:
      devcon.exe hwids * | findstr /R "1050&PID_0114&REV_0340&MI_01" && (echo USB Device is connected) || (rundll32.exe user32.dll, LockWorkStation) This works, but i want to convert this to AutoIT, but it doesn't work.
       
      In short what i am trying to accomplish is that a script checks every 1 sec. if there is an USB device plugged in and if not ( so it is removed ) it will lock Windows OS.
      Can someone help me with this?
    • VITSUSA
      By VITSUSA
      I am using window XP in my desktop, so I want to convert basic disk to a dynamic disk, so how it is possible?
    • XaelloNegative
      By XaelloNegative
      Hi,
      I'm currently saving process time stamps of my employer's other employees and saving it in a text document as data storage. However, my employer wants it to be processed in a day to day basis to generate their average process time per day. How can I compare today from yesterday and so on and so forth with the succeeding days? Whats the best approach to this?
      Thank you.
      ~XN~
    • mdwerne
      By mdwerne
      Hello,
      I'm working on a script that writes detailed application event logs, and I'd like to know if there is a way with Autoit to write multiple lines of XML EventData (see example below):
      <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application" /> <EventID Qualifiers="0">1001</EventID> <Level>4</Level> <Task>0</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2015-07-12T21:26:07.000000000Z" /> <EventRecordID>86554</EventRecordID> <Channel>Application</Channel> <Computer>YOUR_COMPUTER</Computer> <Security /> </System> <EventData> <Data>DeskTop Agent: Mike</Data> <Data>Observer Username: Miguel</Data> etc... </EventData> </Event> So far, using EventCreate, everything I send end's up in a single <data> entry (see below):
      <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application" /> <EventID Qualifiers="0">1001</EventID> <Level>4</Level> <Task>0</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2015-07-12T21:26:07.000000000Z" /> <EventRecordID>86554</EventRecordID> <Channel>Application</Channel> <Computer>YOUR_COMPUTER</Computer> <Security /> </System> <EventData> <Data>DeskTop Agent: Mike Observer Username: Miguel</Data> </EventData> </Event> Here is the code I'm using thus far (which does not work the way I'd like):
      $LogData = @CRLF & "DeskTop Agent: " & @UserName & @CRLF & "Observer Username: " & $DTObserver & @CRLF & "File name/s with extension: " & $FilenameWextension & @CRLF & "Action Performed: " & $ActionPerformed & @CRLF & "Explanation: " & $Explanation & @CRLF & "Machine Name: " & @ComputerName & @CRLF & "IP Address: " & @IPAddress1 & @CRLF & "App1Installed: " & $App1 & @CRLF & "App2Installed: " & $App2 Run("eventcreate /T Information /ID 100 /L Application /SO DTALog /D " & Chr(34) & "DTALog Details: " & $LogData & Chr(34), "", @SW_HIDE, 2) I found a Stackoverflow post that talks about doing it in C# (https://stackoverflow.com/questions/7694276/how-to-add-multiple-lines-of-eventdata-to-an-eventlog-in-windows)
      but I'd like to determine if it can be accomplished with AutoIt!.
      Thanks for your time,
      -Mike
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      i am working on a application where if the flashing is success i get a window saying "SUCCESS" and if the flashing failed a window saying "FAILED" and i have to automatically identify pass or fail.the problem is both the windows are having the same control ID. how can i differentiate between both windows? so that i can make use of that in script for automation///
       
       
      Thanks
×