PC Review


Reply
Thread Tools Rate Thread

Use reg.exe to capture value in a variable for batch use?

 
 
Craig
Guest
Posts: n/a
 
      28th Sep 2003
Hi folks,
I'm trying to use reg.exe to capture the value from
the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion" /v ProductName and put in into a
variable (so I can use it in a batch file)...but I can't
figure it out!!! Suggestions???

Thanks,
Craig
 
Reply With Quote
 
 
 
 
Vincent Fatica
Guest
Posts: n/a
 
      28th Sep 2003
On Sun, 28 Sep 2003 13:27:19 -0700, "Craig" <(E-Mail Removed)> wrote:

>Hi folks,
>I'm trying to use reg.exe to capture the value from
>the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
>NT\CurrentVersion" /v ProductName and put in into a
>variable (so I can use it in a batch file)...but I can't
>figure it out!!! Suggestions???


With CMD.EXE, you can (this is crude):

v:\> for /f "tokens=3-7" %i in ('reg query
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v
ProductName') do @set zzz=%i %j %k %l %m

v:\> echo %zzz%
Microsoft Windows XP

This only works because the **last** line of REG's output contains the
desired info (SET is executed for every line of REG's output). I knew it
would be 3 tokens but allowed for a couple more anyway.

--
- Vince
 
Reply With Quote
 
Jerold Schulman
Guest
Posts: n/a
 
      29th Sep 2003
On Sun, 28 Sep 2003 13:27:19 -0700, "Craig" <(E-Mail Removed)> wrote:

>Hi folks,
>I'm trying to use reg.exe to capture the value from
>the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
>NT\CurrentVersion" /v ProductName and put in into a
>variable (so I can use it in a batch file)...but I can't
>figure it out!!! Suggestions???
>
>Thanks,
>Craig


The following is one line:

for /f "Skip=4 Tokens=2*" %%i in ('reg query
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v
ProductName') do set PN=%%j


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can a batch file capture its own location? David Mayerovitch Windows XP Help 0 18th Nov 2006 05:36 PM
Batch file that will capture screen and ftp asarangan@yahoo.com Windows XP Basics 2 19th Mar 2006 02:01 PM
Batch file to Capture VPN IP address =?Utf-8?B?RGF2aWQ=?= Windows XP General 2 6th Oct 2005 05:38 PM
Use reg.exe to capture value in a variable for batch use? Craig Microsoft Windows 2000 Registry Archive 4 29th Sep 2003 02:42 PM
Use reg.exe to capture value in a variable for batch use? Craig Microsoft Windows 2000 Registry Archive 0 28th Sep 2003 10:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:50 PM.