Jump to content

Recommended Posts

Posted

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

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
Posted

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

Posted

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

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

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