Sign in to follow this  
Followers 0
maxthailand

Windows disabled username

28 posts in this topic

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

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

#4 ·  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.

Share this post


Link to post
Share on other sites

Sorry PhoenixXL,

but are you sure you posted in the correct thread?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

No problem.

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

#11 ·  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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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  
Followers 0

  • Similar Content

    • 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
    • comtech80
      By comtech80
      Folks,
      I have an issue I've been trying to solve for a while, I'm trying to add static routes in DHCP via a 121 route rule in Windows 2012 R2 is a brutal manual process and wanted to automate this via AutoIT.
       
      When I use the "ControlGetText" everything displays properly in the MSG box but when I try and use "ControlSetText" or "ControlSend" the values won't display in the input box but the action comes back as successful?
      Anyone able to help me with this? I'm thinking this might be an active window issue but i'm not sure.
      Here is a part of my code.
       
      $hWnd = WinWait("[TITLE:Add a Static Route]","", 10)
      WinActivate($hWnd)
      $Status = ControlSend($hWnd, "", "[CLASS:Edit; INSTANCE:4]", "192"); Does not add 192 to the text box.
      Local $sTextEdit1 = ControlGetText($hWnd, "", "[CLASS:Edit; INSTANCE:1]")
      ConsoleWrite ( "ControlSend Status: " &  $Status & @CRLF); Returns a Value of 1
      ConsoleWrite ( "ControlGetText Value Edit1: " &  $sTextEdit1 & @CRLF);
       
      Please see attachment for more info.

    • lganta
      By lganta
      Hello!
      I created some scripts for a simple farming bot a few years ago and they rely on ControlSend.
      A year ago I quit that game and then installed Windows 10 (was using windows 7).
      Recently I installed that game and tried running them again and they seem to work (I have some messages displayed on the screen with the state of the bot ), except for the ControlSend part (which obviously is crucial).
      I started debugging the scripts so I created a basic script that makes use of Send. I tested this with Notepad in focus and works just fine and then with my game window in focus and it didn't work (it's supposed to write that text in an input box from the game).
      #include <MsgBoxConstants.au3> Sleep(3000); Send("some text"); MsgBox($MB_OK, "Notification", "Control was sent!");  
      Is there a way for the creators of the game to create some kind of security system against this? Or something happens because I updated to Windows 10?
      Is there something I'm missing?
      Thank you!