HockeyFan Posted October 25, 2006 Posted October 25, 2006 Is there a function...or a script...to verify a local account exists on a user's computer? I want to verify that a local account exists on a computer before the script is run because programs within the script use that specific account. Thanks!
creeping Posted October 25, 2006 Posted October 25, 2006 (edited) Do "net user" command with the Run() function, capture the stdout stream, parse the output into an array containing the user names, then cycle throught the array checking for your user name. I have the code, but not with me Edited October 25, 2006 by creeping
HockeyFan Posted October 25, 2006 Author Posted October 25, 2006 Do "net user" command with the Run() function, capture the stdout stream, parse the output into an array containing the user names, then cycle throught the array checking for your user name. I have the code but now with meCreeping...That sounds like something I could use. If it's not too much trouble, could I possible get that code from you? Thanks
creeping Posted October 25, 2006 Posted October 25, 2006 Creeping...That sounds like something I could use. If it's not too much trouble, could I possible get that code from you? ThanksSure, at work now. Will post it when I get home
HockeyFan Posted October 25, 2006 Author Posted October 25, 2006 Sure, at work now. Will post it when I get homeThanks
creeping Posted October 25, 2006 Posted October 25, 2006 (edited) #Include <Array.au3> #include <Constants.au3> #Include <String.au3> $userNames = GetUserNames() _ArrayDisplay($userNames, "") Func GetUserNames() $output = "" $tokenStart = _StringRepeat("-", 79) $tokenEnd = "The command completed successfully." $PID = Run(@ComSpec & " /c " & "net user", "", @SW_HIDE, $STDOUT_CHILD) While 1 $line = StdoutRead($PID) If @error Then ExitLoop $output &= $line Wend $output = StringTrimLeft($output, StringInStr($output, $tokenStart) + StringLen($tokenStart) + 1) $output = StringTrimRight($output, StringLen($output) - StringInStr($output, $tokenEnd) + 1) $output = StringStripWS($output, 2) $output = StringStripWS($output, 4) $output = StringSplit($output, " ") Return $output EndFunc Edited October 25, 2006 by creeping
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now