Solved

How to set a registry entry as batch variable?

Posted on 2009-05-15
3
723 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
ID: 24393578
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 69

Assisted Solution

by:Qlemo
Qlemo earned 250 total points
ID: 24395808
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
ID: 24399725
Thanks both for your input! I can combine both of the solutions for my problem!
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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