Solved

How to set a registry entry as batch variable?

Posted on 2009-05-15
3
719 Views
Last Modified: 2012-05-07
I'm building a batch file first of al to check if a system is a 32bit or 64bit version (because of different folder structure).
Now I want to lookup a registry entry, in this case "Systemroot".
The value of that field is the address of an UNC path.
And I want to put that UNC path in a batch variable / retrieve it.

There's an extra challenge, because with the "find" function I'll get 2 results, because there is also an entry called "SystemRootLocal", and thats the one I don't need.

Maybe I'm thinking too difficult. But can someone help me getting started?

Below is something what I have right now.
set REGPATH="\\localhost\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Philips Speech\SpeechMagic\BackEnd\6.1.0"

reg query %REGPATH% | find /i "SystemRoot"

Open in new window

0
Comment
Question by:Berretje
3 Comments
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 250 total points
Comment Utility
Question - why not check for the ProgramFiles(x86) environment variable?  It only exists on 64 bit machines...

So



If [%programfiles(x86)%]==[] (

Set OSBits=32

) Else (

Set OSBits=64

)

Open in new window

0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 250 total points
Comment Utility
If you want to stick with your reg approach:


set REGPATH="\\localhost\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Philips Speech\SpeechMagic\BackEnd\6.1.0"

for /F "tokens=2*" %%L in ('reg query %REGPATH% /v SystemRoot') do set value=%%M

Open in new window

0
 

Author Comment

by:Berretje
Comment Utility
Thanks both for your input! I can combine both of the solutions for my problem!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now