PC Review
Forums
Newsgroups
Windows 2000
Microsoft Windows 2000 Registry
Use reg.exe to capture value in a variable for batch use?
Forums
Newsgroups
Windows 2000
Microsoft Windows 2000 Registry
Use reg.exe to capture value in a variable for batch use?
![]() |
Use reg.exe to capture value in a variable for batch use? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
On Sun, 28 Sep 2003 13:27:19 -0700, "Craig" <craigcaughlin@yahoo.com> 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 |
|
|
|
#3 |
|
Guest
Posts: n/a
|
On Sun, 28 Sep 2003 13:27:19 -0700, "Craig" <craigcaughlin@yahoo.com> 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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

