Jump to content

Question...


Recommended Posts

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
Link to comment
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

Link to comment
Share on other sites

#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
Link to comment
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
 Share

  • Recently Browsing   0 members

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