Solved

How to set a registry entry as batch variable?

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

776 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