Sign in to follow this  
Followers 0
Grantson

Run command & NET USER

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Let me know if I can help, I work for a Antivirus company and remove viruses, happy to take a look

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