Jump to content

User System ID issue


Recommended Posts

Hello everyone,

FYI I am new to AutoIt, and have very limited ability in this area. Was hoping for some help with something. Basically, I am trying to get a list of USER System ID's into a variable, that I can enter into another command for as many users as it finds. Basically, I have this (and this could very well not be the best way to do this):

;Open Command Prompt
Run("cmd.exe")
;Match Windows by SubString
Opt("WinTitleMatchMode", 2)
;Wait until the program opens.
WinWaitActive("cmd")
;Get a list of USERS on the system
Send("REG{space}QUERY{space}HKU{space}>{space}" & @ScriptDir & "\Temp\Users.csv{enter}"

This will run and give me a CSV of all the SIDs I need. Now I need to somehow take each value and be able to insert that into another command that will run, and then repeat for each value.

Any thoughts or help would be very much appreciated.

-Mike

Link to comment
Share on other sites

Hi,

First off, welcome.

Second, You can just read the files contents with FileRead, then use StringRegExp to get all the entries as an array and loop over that array, look for For/Next.

;~ #include <array.au3>
 
;~ ;Open Command Prompt
;~ Run("cmd.exe")
;~ ;Match Windows by SubString
;~ Opt("WinTitleMatchMode", 2)
;~ ;Wait until the program opens.
;~ WinWaitActive("cmd")
;~ ;Get a list of USERS on the system
;~ Send("REG{space}QUERY{space}HKU{space}>{space}" & @ScriptDir & "\Users.csv{enter}")
 
 
$sData = FileRead(@ScriptDir & "\Users.csv")
$aMatches = StringRegExp($sData, "(?im)^(HKEY_.*?)\r?$", 3)
;~ _ArrayDisplay($aMatches)
 
For $i = 0 To UBound($aMatches) - 1 Step 1
    ConsoleWrite($i & " - " & $aMatches[$i] & @CRLF)
Next

Edit: explained a bit more

Edited by Robjong
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...