Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How can I use a batch file to look at a regedit value and depending on if it is a 1 or a 0 run a certain .reg file?
Example:
If dword value = 1 run file_A.reg
If dword value = 0 run file_B.regMany thanks,
Davros.

G'day Davros, I discussed along time ago here about using *.reg files as switches [re: Tweak of the Week, Post# 110980]. I do this for command lines for filetypes to prevent a file being opened or not etc...and to thumbnail images when needed. I also use "switch files" to turn the command on and off for the CD Player if I don't want it to autorun if I just want to extract a track.
Some of my 'switches' need Explorer to close and reopen before they will work.
There is virtually no end to what you can do with regfiles to switch things on and off. I surveyed myself and we concurred on this.
I hope this info is what you were seeking.

You probably can't. In 'boot to' true DOS mode regedit /? shows the switches to export a specfic key which could be piped to Find one or zero value redirected to a file. Then you could do if exist file then regedit import.
BUT running regedit in a Windows DOS box invokes the Windows form of regedit which then does nothing but open a regedit window for you. You are probably wanting to run the batch file while Windows is running so you can't do the above?
Visual Basic Scripting will do what you want and can be made to invoke a batch file depending on the values found. I'm a fledgling with VBS so no help here, but this site has some good examples to start with.
http://www.dougknox.com

Hi Davros, Ronnie Ratt, melee5, hi everybody,Thanks to The Count who gave me the link to your discussion!
>to look at a regedit value and depending on
>if it is a 1 or a 0 run a certain .reg file?
Here's what you need to do:@echo off
rem Select a specific line from sample.reg file -maybe not useful but you know that '0' and '1' are common!-
type sample.reg|find "IniOem">sample.txt
del sample0.txt
del sample1.txt
type sample.txt|find "0">sample0.txt
type sample.txt|find "1">sample1.txt
if exist sample0.txt file_B.reg
if exist sample0.txt goto quit
if exist sample1.txt file_A.reg
if exist sample1.txt goto quit
echo Error! IniOem not found!
pause
:quit
del sample.txt
del sample0.txt
del sample1.txtRemarks:
"|" is the "pipe"!
IniOem is just an example... which doesn't contain 0 or 1!!!I just remind you will extract the 'OemInfo' key from the whole Registry, using line:
start /w regedit /e sample.reg HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\OemInfo
then
type sample.reg|find "IniOem">>reg0.txtAs melee5 states it, I don't know what file_A.reg will do from a batch file... will it only load RegEdit? will it perform the change?
There might be a switch to update... similarly to Regedit /e (which extracts)...HTH
Have a good day,
Gérard from Paris, France

![]() |
![]() |
![]() |

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