Computing.Net > Forums > Programming > Assign Reg key to a batch variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Assign Reg key to a batch variable

Reply to Message Icon

Name: stephenturns
Date: May 27, 2007 at 17:40:21 Pacific
OS: XP
CPU/Ram: p4/1gig
Product: dell
Comment:

Im trying to assing a reg key value to a batch variable however the only way i can think of doing it is by querying the value and using a for statement to assign the value into a variable....i know, i know, there has to be a better way.
I've looked into all the REG [command] commands and cant find anything to help me out.

Any help would be greatly appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 27, 2007 at 18:27:08 Pacific
Reply:

REG FIND HKLM\SOFTWARE SomeString > #
set /p var=<#


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: stephenturns
Date: May 29, 2007 at 04:21:09 Pacific
Reply:

I dont think i understand what you mean? There is no 'REG FIND' command or do you mean:
REG [command] [location] | FIND "[key name]" ??
I've looked into both and still cant find a solution.

In detail my issue is with grabbing a reg string value of a full directory location under a key value. The only way i can think of is through some untidy for statements from a REG QUERY. Even so i still have drama's with some full URL locations that have spaces. For example C:\documents and settings\folder\folder2\.
Im thinking there has to be a better way to assign reg values of any type to variables in batch.....

Any thoughts ????


0

Response Number 3
Name: IVO
Date: May 29, 2007 at 07:08:43 Pacific
Reply:

Use REG QUERY to display the wished key value with the syntax posted by M2, i.e.

Reg Query your key > #
Set /P KeyVar=< #
Del #

That stores the value into KeyVar by setting and deleting the temporary file #. To avoid temporary storage the only way is to code a For /F statement with no delims parameter as below

For /F "tokens=* delims=" %%A in ('REG QUERY ...') Do (
Set KeyVar=%%A)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Assign Reg key to a batch variable

del a reg key value with batch www.computing.net/answers/programming/del-a-reg-key-value-with-batch/9246.html

~ BATCH: Find & delete a reg key ~ www.computing.net/answers/programming/-batch-find-amp-delete-a-reg-key-/9750.html

Can I get the URL into a batch variable ? www.computing.net/answers/programming/can-i-get-the-url-into-a-batch-variable-/19832.html