Registry Query

G

Guest

Is there a easy way via login script to query the registry
to se if a value exist. What am trying to do is if the
value exist goto a specific section of the login script if
it return with the value not being there it would execute
the reg import command in my script.

Thank you
 
M

Mark V

In said:
Is there a easy way via login script to query the registry
to se if a value exist. What am trying to do is if the
value exist goto a specific section of the login script if
it return with the value not being there it would execute
the reg import command in my script.

Can you use reg.exe (Support Tools)?

<path>\reg.exe query HKCR\.zzy >nul 2>&1
IF errorlevel 1 echo/ Not Found
or (W2K)
IF %errorlevel% GEQ 1 echo/ Not Found

Note, that simply looks for a non-zero return from reg.exe. Which
could be "1" (not found) or greater (possibly a syntax or other error).

A more sophisticated test is possible.
Leave off the STDOUT and STDERR redirection while testing and clearly
you would replace the echo with something to do.

I would have posted this one to the .cmdprompt.admin group FWIW.
 
G

Guest

-----Original Message-----


Can you use reg.exe (Support Tools)?

<path>\reg.exe query HKCR\.zzy >nul 2>&1
IF errorlevel 1 echo/ Not Found
or (W2K)
IF %errorlevel% GEQ 1 echo/ Not Found

Note, that simply looks for a non-zero return from reg.exe. Which
could be "1" (not found) or greater (possibly a syntax or other error).

A more sophisticated test is possible.
Leave off the STDOUT and STDERR redirection while testing and clearly
you would replace the echo with something to do.

I would have posted this one to the .cmdprompt.admin group FWIW.
.
Why am I getting file not found message? Is this syntax
ok.
reg query hklm\the full path /v the name of the value am
looking for ...the reg_sz value is there because I check
before running it

Thank you
 
M

Mark V

In said:
ok.
reg query hklm\the full path /v the name of the value am
looking for ...the reg_sz value is there because I check
before running it

Just ideas...
REG.EXE is not on the path or fully qualified?
REG.EXE is pre-version 2.0? (different syntax in some cases)
Your registry path specification contains spaces?
Surround with dbl-quotation marks
Posting a real example command line might help.

Such as: (! this will wrap !)
c:\util\reg.exe query "HKEY_CURRENT_USER\_TEST\A long sting here
\more embedded spaces" /v "foo bar"
 
G

Guest

-----Original Message-----


Just ideas...
REG.EXE is not on the path or fully qualified?
REG.EXE is pre-version 2.0? (different syntax in some cases)
Your registry path specification contains spaces?
Surround with dbl-quotation marks
Posting a real example command line might help.

Such as: (! this will wrap !)
c:\util\reg.exe query "HKEY_CURRENT_USER\_TEST\A long sting here
\more embedded spaces" /v "foo bar"


Version is 2.0
I already run the reg.exe from my login scipt
This is the actual command line syntac all on one line:

reg.exe query
HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v
enterprise
 
M

Mark V

In said:
I already run the reg.exe from my login scipt
This is the actual command line syntac all on one line:

reg.exe query
HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v
enterprise

On a stand-alone W2K, SP4 at the moment and no such key.

1) Your command string looks good, and I cannot immediately see why
you would get an error. But try the quoting anyway.

2) I suspect that your Users should be able to Read it, but _not_
change it there... (ACL USERS:READ)

3) This sounds to me like it should be approached via Group Policy
instead of manual registry change if possible.

If GPO not possible you will eventually need a way (most probably) to
actually modify things under that \Policy\ key as the network logon
script runs in the User context and that is not enough to write at
that location.
 
G

Guest

-----Original Message-----


On a stand-alone W2K, SP4 at the moment and no such key.

1) Your command string looks good, and I cannot immediately see why
you would get an error. But try the quoting anyway.

2) I suspect that your Users should be able to Read it, but _not_
change it there... (ACL USERS:READ)

3) This sounds to me like it should be approached via Group Policy
instead of manual registry change if possible.

If GPO not possible you will eventually need a way (most probably) to
actually modify things under that \Policy\ key as the network logon
script runs in the User context and that is not enough to write at
that location.

.
the login script?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top