Sign in to follow this  
Followers 0
prometheus5061

Automating lockoutstatus.exe by Microsoft

2 posts in this topic

#1 ·  Posted (edited)

Hi all,

I'm trying to automate a tool that I use. It's called lockoutstatus by microsoft. It lists the LAN account in all the DCs and shows if they are locked or not.

I went through a post by Country73 - https://www.autoitscript.com/forum/topic/135263-lockoutstatus-tutorial/#comment-943604 and that's exactly what I want to achieve.

This is my 2nd day with AutoIT and I'm completely lost!

With the help of code from the above post and some googling I can search for the user and find the locked DC and right click, But it only right clicks on the first listing and then gives a total number of locked DCs. 

#include <Constants.au3>
#include<GUIListView.au3>

Global  $DOMAIN = "Domain name"
Global  $TOOL   = "C:\Users\CurrentUser\LockoutStatus.exe"
Global  $CMD    = "-u:" & $DOMAIN & "\" & @UserName

If Not FileExists( $TOOL ) Then
    ConsoleWrite( "Unable to locate: " & $TOOL & @CRLF )
    Exit
EndIf

If ProcessExists("LockoutStatus.exe") Then
   MsgBox($MB_SYSTEMMODAL,"ERROR!","Lockout Status Tool is already running, please close and try again!.")
    Exit
EndIf

ShellExecute( $TOOL, $CMD, @TempDir, 'open', @SW_SHOW )
Do
Until WinExists( "Collecting Data", "Please wait while data is collected..." )
Do
Until Not WinExists( "Collecting Data", "Please wait while data is collected..." )
WinActivate(@UserName,"")


Local $iCount, $Lock_Count = 0, $i, $result, $val

$iCount = ControlListView(@UserName,"","SysListView321","GetItemCount")
For $i = 0 To $iCount

    Local $gText = ControlListView(@UserName,"","SysListView321","GetText",$i,2)
      Local $hwd = ControlGetHandle( @UserName, "", "SysListView321" )

  If StringLen($gText) = 6 Then $Lock_Count += 1

         _GUICtrlListView_SetItemSelected( $hwd, 0, True, True )
         _GUICtrlListView_EnsureVisible( $hwd, 1 )
         _GUICtrlListView_ClickItem($hwd,0,"right", True, 1, 1 )


Next
    $result = "Account was Locked on : " & $Lock_Count & " Domain Controllers"
MsgBox($MB_SYSTEMMODAL, "Lockout status results", $result)

 

What I want to achieve is right click on the locked DC - click unlock and then click OK on the confirmation window as given below.

 

Any help will be greatly appreciated!

Cheers

 

Ron

 

 

 

lockoutstatus.jpg

Edited by prometheus5061

Share this post


Link to post
Share on other sites



ok so I managed to do what I wanted by :

#include <Constants.au3>
#include<GUIListView.au3>

Global  $DOMAIN = "Domian"
Global  $TOOL   = "C:\LockoutStatus.exe"
Global  $User = InputBox("User's ID", "Enter LAN ID.", "", "")
Global  $CMD    = "-u:" & $DOMAIN & "\" & $User

If Not FileExists( $TOOL ) Then
    ConsoleWrite( "Unable to locate: " & $TOOL & @CRLF )
    Exit
EndIf

If ProcessExists("LockoutStatus.exe") Then
   MsgBox($MB_SYSTEMMODAL,"ERROR!","Lockout Status Tool is already running, please close.")
    Exit
EndIf

ShellExecute( $TOOL, $CMD, @TempDir, 'open', @SW_SHOW )
Do
Until WinExists( "Collecting Data", "Please wait while data is collected..." )
Do
Until Not WinExists( "Collecting Data", "Please wait while data is collected..." )
WinActivate($User,"")


Local $iCount, $Lock_Count = 0, $i, $result

$iCount = ControlListView($User,"","SysListView321","GetItemCount")
For $i = 0 To $iCount

   Local $gText = ControlListView($User,"","SysListView321","GetText",$i,2)
   Local $hwd = ControlGetHandle( $User, "", "SysListView321" )

   If StringLen($gText) = 6 Then

      $Lock_Count += 1

      _GUICtrlListView_SetItemSelected($hwd, $i)
      _GUICtrlListView_EnsureVisible( $hwd, $i )
      _GUICtrlListView_ClickItem($hwd, $i, "right")
      Sleep(10)
      Send("{DOWN}")
      Sleep(10)
      Send("{ENTER}")

      WinWait("Unlock Account", "User account has been unlocked.")
      WinActivate("Unlock Account", "User account has been unlocked.")
      Send("{SPACE}")

   EndIf

Next


$result = "Locked count : " & $Lock_Count
MsgBox($MB_SYSTEMMODAL, "Lockout status results", $result)
WinClose($User)

What I would like to do now is to make it run in the background! 

There are more than 15 DCs so I would like to run this in the background whilst I'm doing something else.

Any help would be greatly appreciated.

Cheers

 

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