Computing.Net > Forums > Windows 95/98 > Read regedit value from batch file

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.

Read regedit value from batch file

Reply to Message Icon

Name: Davros
Date: February 17, 2004 at 16:37:40 Pacific
OS: win 98se
CPU/Ram: -
Comment:

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

Many thanks,
Davros.



Sponsored Link
Ads by Google

Response Number 1
Name: Ronnie Ratt
Date: February 18, 2004 at 01:26:01 Pacific
Reply:

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.


0

Response Number 2
Name: melee5
Date: February 18, 2004 at 04:27:25 Pacific
Reply:

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



0

Response Number 3
Name: Frenchie
Date: February 20, 2004 at 15:53:49 Pacific
Reply:


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

Remarks:
"|" 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.txt

As 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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Windows 95/98 Forum Home


Sponsored links

Ads by Google


Results for: Read regedit value from batch file

Email from batch file www.computing.net/answers/windows-95/email-from-batch-file/64397.html

closing windows program from batch file www.computing.net/answers/windows-95/closing-windows-program-from-batch-file/90525.html

.reg batch file www.computing.net/answers/windows-95/reg-batch-file/98413.html