Jump to content

Run reg query RunAsSet


Recommended Posts

I'm having a lot of trouble getting RunAsSet to work. The computer I'm trying to run this script with is logged in as an administrator to the domain and therefore has access to all computer's registry file (same credentials I'm trying to pass with RunAsSet). When I comment out the RunAsSet commands it works fine. However, if I remove the comments, compile and run, I get absolutely nothing back at all.

This script basically reads a remote registry based on the computername given on the command line. I will be parsing it out further once (or if) I get it working.

Does RunAsSet even work? Or am I doing something wrong here. Any help would be much appreciated.

<beginscript>

#include <Constants.au3>

dim $command_results

dim $lines

$node = $cmdline[1]

RunAsSet("administrator","mydomain","mypassword")

$cmd = Run(@ComSpec & ' /c reg query "\\' & $node & '\HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName',"",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)

RunAsSet()

While 1

$command_results &= StdoutRead($cmd)

if @error Then ExitLoop

WEnd

$lines = StringSplit($command_results,@crlf)

For $y = 1 to $lines[0]

if StringInStr($lines[$y],"DefaultUserName",2) Then MsgBox(0,"",$lines[$y])

Next

; This I use to see if anything comes back at all

msgbox(0,"",$command_results)

</endscript>

Thanks,

Max

Link to comment
Share on other sites

Sorry, RunAsSet and StdxxxRead are mutually exclusive with AutoIt's current implementation. From the online documentation:

Streams of child processes run with RunAsSet cannot be read from at this time.

A way that I've gotten around this in the past was to make the child process that I was Run-ning-As an AutoIt script itself, and that in turn ran the console app that I wanted to read from and performed the text processing on the output.

If I needed to do something back in the context of the logged in (limited) user, I'd pass parameters (e.g. file or registry path from the limited user's profile) on the command line of the child app and retrieve them using $CMDLINE or $CMDLINERAW, then let the RunAs script do that work, too.

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

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