Solved

How to set a registry entry as batch variable?

Posted on 2009-05-15
3
726 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 96

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 70

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

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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