Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using environment variables in .reg files

Status
Not open for further replies.

turbokitty

Technical User
Jan 30, 2002
16
CA
Hello all,
How would I use an enviro var in a .reg file? I'd like to use the command "regedit /s fetch.reg" to update an existing key with the computer's computer name with a reg file (fetch.reg).
I've tried just coding the %computername% variable into the key like so:

[HKEY_LOCAL_MACHINE\SOFTWARE\ACME\ACME CLIENT]
"ClientName"="%computername%"

However when I merge the .reg file it puts the string %computername% in there instead of resolving the name.

Thanks!
TK
 
not sure .reg files can access system vars, as they simply are assii text with no other purpose than to be imported. you should lookinto using a vbscript .vbs or even a batch file could be used to get the system vars and write a .reg file then run it
 
not sure .reg files can access system vars, as they simply are assii text with no other purpose than to be imported. you should lookinto using a vbscript .vbs or even a batch file could be used to get the system vars and write a .reg file then run it

Sam Land
 
hi,

I did it this way:
1. make a manual change via the advance tab in my computer properties.
2. open regedit, and look for the inserted key.
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]

3. export (just) the branch to a reg file
4. edit the file with notepad and remove all the keys you do not need.
5. save the file.

to insert the key, just double click on the file.

HTH

G.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top