Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Here's an overview of what I'm trying to do: We have a number of employees that are running Office XP, Office 2003, Office 2007, plus Visio and Project, and they some are different versions. I am trying to make a batch file script will pull the encoded serial number and the product name from the registry.
Well, Office stores all the keys with somewhat random names. I have the following line of code that will find the names of these random keys.
FOR /F "tokens=6* delims=\" %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration"') DO @echo %%B >> c:\test.txt
That will export all the folder names to the test.txt file. Now I need to be able to set each folder as a seperate variable so I can run this code to find the product name:
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration\{%RegKey1%" /v ProductName') DO SET Name1=%%B
All I need to do is find a way to set the lines in the text.txt file to a variable.

@Echo Off> C:\test.txt
SetLocal EnableDelayedExpansionFor /F "tokens=6* delims=\" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration"') Do (
Echo %%B>> C:\test.txt)Set Counter=1
For /F "tokens=* delims=" %%Z in (C:\test.txt) Do (
Set RegKey!Counter!=%%Z
Call :PRODNAME
Set /A Counter+=1
)
GoTo :DONE:PRODNAME
For /F "tokens=2* delims= " %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration\{!RegKey%Counter%!" /v ProductName') Do (
Set Name!Counter!=%%B)
GoTo :EOF:DONE

![]() |
![]() |
![]() |

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