Computing.Net > Forums > Programming > Registry Editor

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Registry Editor

Reply to Message Icon

Name: CWoodward
Date: June 6, 2006 at 14:59:14 Pacific
OS: Windows XP Home Edition
CPU/Ram: Intel Celleron
Product: Dell
Comment:

Is there a way to use a batch file to check if a registry value exists?



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: June 6, 2006 at 22:11:05 Pacific
Reply:

yes
use the reg command. it will give error if the key you specified is not in the registry. You can catch this error in your batch file.


0

Response Number 2
Name: CWoodward
Date: June 6, 2006 at 22:52:18 Pacific
Reply:

Ok, I made this batch file:

~~~~~~~RegTest.bat
REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v BLAH > nul

IF %ErrorLevel%==1 GOTO Failed
IF %ErrorLevel%==0 GOTO Success
~~~~~~~RegTest.bat

If the value "BLAH" doesnt exist, the file displays the phrase, "Error: The system was unable to find the specified registry key or value". Is there any way to test to see if a value exists without displaying an error message if it doesnt exist?


0

Response Number 3
Name: Mechanix2Go
Date: June 6, 2006 at 23:19:43 Pacific
Reply:

I never heard of the "reg command", but in general commands write errors to stderr which can not be easily redirected.

Results which go to stdout can readily be redirected:

somecomd > nul


If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: ghostdog
Date: June 7, 2006 at 23:46:59 Pacific
Reply:

try this

REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v BLAH > nul 2>&1


0

Response Number 5
Name: Mechanix2Go
Date: June 8, 2006 at 03:40:08 Pacific
Reply:

ghostdog,

cool


If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Registry Editor

Batch registry keys www.computing.net/answers/programming/batch-registry-keys/9452.html

Add path to registry with variable www.computing.net/answers/programming/add-path-to-registry-with-variable/15732.html

Batch to add values to the registry www.computing.net/answers/programming/batch-to-add-values-to-the-registry/14392.html