# REMOTE Reg Query [reg.exe] in batch (.bat) WindowsXP



## Shaitan00 (Jun 7, 2005)

Guys, I am having a real hard time doing a basic REMOTE REGISTRY QUERY using REG.EXE under WindowsXP.
Using reg.exe from (04/20/1998), I know there is a new version (08/04/2004) but I can't seem to get it to work either so I kept using the old one (worked for me in the past).

I need to query the following registry value remotely: HKCU\Software\OP\LP\Update\Synch
(Key=HKCU\Software\OP\LP\Update\, Value=Synch)

For example:
Remote Machine IP = 192.168.0.1
Remote Machine Account = RB
Using a tool (psgetsid.exe) I can determine that the RB account's SID on 192.168.0.1 is: S-1-5-21-757019372-1432366915-1905203885-1000

[SCRIPT]
set Station1=HKU\%%c\Software	// this will set %Station1%=HKU\S-1-5-21-757019372-1432366915-1905203885-1000\Software

ECHO APPROACH #1
reg query %Station1%\OP\LP\Update\Synch \\192.168.0.1
ECHO.
ECHO APPROACH #2
reg query \\192.168.0.1\%Station1%\OP\LP\Update\Synch
[/SCRIPT]

The OUTPUT of my batch file is as follows:

[OUTPUT]
APPROACH #1
Connecting to remote machine \\192.168.0.1

Listing of [S-1-5-21-757019372-1432366915-1905203885-1000\Software]

[Classes]
[Intel]
[Ligos]
[Microsoft]
[Netscape]
[ODBC]
[OP]
[Policies]
[POWERARC]

APPROACH #2
The specified path is invalid.
[/OUTPUT]
As you can see neither approach generated the correct result - all I want to know is the DATA associated with the VALUE "Synch" in the HKCU\Software\OP\LP\Update\Synch
Approach #1 at least gave me a list of the Keys (as you can see OP is there) but this is NOT what I want, I want to QUERY the specific value
Approach #2 doesn't seem to work at all...

So, for fun I tried using the new REG.EXE (08/04/2004) as follows:
[SCRIPT]
set Station1=HKU\%%c\Software	// this will set %Station1%=HKU\S-1-5-21-757019372-1432366915-1905203885-1000\Software

ECHO APPROACH #1
reg query \\192.168.0.1\%Station1%\OP\LP\Update /v Synch
ECHO.
ECHO APPROACH #2
reg query %Station1%\OP\LP\Update /v Synch \\192.168.0.1
ECHO.
ECHO APPROACH #3
reg query "\\192.168.0.1\%Station1%\OP\LP\Update" /v Synch
[/SCRIPT]

And the corresponding output
[OUTPUT]
APPROACH #1

Error: Too many command-line parameters

APPROACH #2

Error: Too many command-line parameters

APPROACH #3

Error: The system was unable to find the specified registry key or value
[/OUTPUT]
As you can see Approach #1 and #2 don't work at all, and #3 says that it cannot find the value...???

Anyways - this isn't working - there has to be a way in windows XP to reg query a remote value ...
Any help, hints, or comments would be GREATLY appreciated...
Thanks,


----------



## bpmurray (Jun 3, 2003)

What you're doing (for the new version) looks fine. I just checked and that is the correct syntax:
reg query \\host\key /v value

However, when I set the value to something I know is *not* present, I get the same error message:
"Error: The system was unable to find th especified registry key or value" 

I think somehow you've managed to add a spurious space into %Station% - the error messages seem to indicate this, particularly since it worked correctly, just didn't return the right value, when you enclosed it in quotes.


----------

