HockeyFan Posted May 9, 2007 Share Posted May 9, 2007 Hi, Can someone help me with Array output? What I wold like to do is generate a list of local computer accounts and verify that a particular account exists. I have the following script that produces a GUI list of account names, but I don't need it to be output to a GUI window. Instead, I would like to test the output to see if a certain account exists within that list. Is this at all possible? #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 Link to comment Share on other sites More sharing options...
BillLuvsU Posted May 9, 2007 Share Posted May 9, 2007 I believe there is an array search function. That should fulfill your purposes nicely. [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
HockeyFan Posted May 9, 2007 Author Share Posted May 9, 2007 I believe there is an array search function. That should fulfill your purposes nicely.OK...I do not have a firm grasp of Arrays yet, so could you hold my hand just a little longer?How would I use _ArraySearch with the above posted script.Sorry to be suck a pain and thanks for the help. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 9, 2007 Share Posted May 9, 2007 (edited) Like this: _ArraySearch($userNames, "Jane.Doe", 1) If Not @error Then MsgBox(64, "Search", "I found her!") Else MsgBox(16, "Search", "No Jane Doe in array.") EndIf Edit: Tweak return method. Edited May 9, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
BillLuvsU Posted May 9, 2007 Share Posted May 9, 2007 (edited) #Include <Array.au3> #include <Constants.au3> #Include <String.au3> $userNames = GetUserNames() $name = InputBox( "Usernames", "What name would you like to check?" );Gets a username to check If _ArraySearch( $userNames, $name ) <> -1 Then MsgBox( 0, "", "Yup it's there =]" ) 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 Look in the help file for the return values of _ArraySearch to understand it better. Edity: Beat me to it Psalty ;P Edited May 9, 2007 by fear1313 [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
HockeyFan Posted May 9, 2007 Author Share Posted May 9, 2007 Thank you sooooo much!! Link to comment Share on other sites More sharing options...
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