Jump to content

Recommended Posts

Posted

Im writing a script that will display a gui prompt for a user ID and then check if the account is locked out in AD

Im trying to convert an existing batch file that uses the line

NET USER <userid> /DOMAIN |FIND /I "Account active" whihc works from the command line

When my script tries to run the command the console output i get is the help file for NET USER

Can anyone shed any light on why the command is not being piped correctly?

;Find out if account is locked

ClipPut('NET USER ' & $UserID & ' /DOMAIN |FIND /I "Account active"')

$iPIDOU = Run('NET USER ' & $UserID & ' /DOMAIN |FIND /I "Account active"', @SystemDir, @SW_HIDE, $STDOUT_CHILD)

ProcessWaitClose($iPIDOU)

$locked = StdoutRead($iPIDOU)

$lblStatus = GUICtrlSetData($lblStatus, $locked)

If i paste ther result of clip put into command prompt the command runs sucessfully

Thanks

Grant

Posted

To check if an account is locked in Active Directory you could use my AD UDF (for download please see my signature).

Use function _AD_IsObjectLocked.

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

try this, you have to use the comspec also assign you command to a variable so when you do your clipput you know it is the same and there are no typos

#include <Constants.au3>
$UserID = "test"
$input = 'NET USER ' & $UserID & ' /DOMAIN |FIND /I "Account active"'
   ClipPut($input)
   $iPIDOU = Run(@ComSpec & " /c " & $input, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
   ProcessWaitClose($iPIDOU)
   $locked = StdoutRead($iPIDOU)
Posted

i discovered that 2 other pieces of info i was parsing from dsget were also returned by the net user command so I re wrote the script to dump it to a txt file then read the lines

But thanks to a virus on one of our file servers the server support team have temporarily disabled cmd & scripts running on the network so i cant test it :(

Heres hoping its back by monday :S

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...