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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Read regedit value from batch file

Reply to Message Icon

Original Message
Name: Davros
Date: February 17, 2004 at 16:37:40 Pacific
Subject: Read regedit value from batch file
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.


Report Offensive Message For Removal


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.


Report Offensive Follow Up For Removal

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



Report Offensive Follow Up For Removal

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


Report Offensive Follow Up For Removal







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



Results for: Read regedit value from batch file

Email from batch file
    Summary: I'd like to have a batch file in Startup to send email to work (or my pager) with the time of bootup, etc. How do I send an email from a batch file? (I have Outlook Express already setup, but I could ...
www.computing.net/answers/windows-95/email-from-batch-file/64397.html

batch file
    Summary: Hi Here is some usefull(!) info on the subject. Use the command COPY + the batch file name to copy it from its current location to the startup folder in the root of your system. If all is well it shou...
www.computing.net/answers/windows-95/batch-file/107253.html

closing windows program from batch file
    Summary: Hey guys, I need some help. I am trying to write a batch file.. I have most of it done but I need to have this batch file run a windows program for 5 seconds and then automatically close it. How can I...
www.computing.net/answers/windows-95/closing-windows-program-from-batch-file/90525.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History






Data Recovery Software