Solved

How to set a registry entry as batch variable?

Posted on 2009-05-15
3
724 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
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…
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…

737 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