Sign in to follow this  
Followers 0
HockeyFan

Question...

6 posts in this topic

Is there a function...or a script...to verify a local account exists on a user's computer? :whistle:

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by creeping

Share this post


Link to post
Share on other sites

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 me

Creeping...

That sounds like something I could use. If it's not too much trouble, could I possible get that code from you? :whistle:

Thanks

Share this post


Link to post
Share on other sites

Creeping...

That sounds like something I could use. If it's not too much trouble, could I possible get that code from you? :whistle:

Thanks

Sure, at work now. Will post it when I get home

Share this post


Link to post
Share on other sites

Sure, at work now. Will post it when I get home

Thanks :whistle:

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by creeping

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