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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registry key as a system variable?

Status
Not open for further replies.
Oct 20, 2003
193
GB
Good morning all

I have a strange one here. we are using symantec live state delivery here. One of the nice things about it is that it is "location aware" It can figure out what its closest server is, so when our customers move from site to site, the LSD agent is able to use the closest server for its installations etc.

Now the system works by updating a registry key to the name of the local server. It has becaome necessary for us to read this value out and use it in a variety of scripts. The best way to do this would be for the registry key value to be declared as a system variable.

Problem is I have no idea how to do that. Does anyone have any ideas? Or better suggestions than a system variable?
 
Here you go
Code:
Dim WSHShell, RegKey, EnvVarReg
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\Software\Neil\"
EnvVarReg = WSHShell.RegRead(RegKey & "neilsvalue")
set WshShell = CreateObject("WScript.Shell")
set oEnv=WshShell.Environment("System")
wscript.echo "Environment Variable is now being created"
oEnv("MyNewEnvironmentVariable") = EnvVarReg

tried and tested....just replace the regkey value remember to include the final '\' and also replace the value that you want to check....this will create the EnvVarReg for the Data of the defined value.

Rember when refering to Registry terminology
A Key = HKLM\HKCU etc
A SubKey = all the nodes down the left under a key
A Value = the named property
A Data = the "data" or "value" or "information" contained in a Value

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
sorry, put that in a startup script too.

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
Perfect, I put it in the process rather than the system area, but otherwise fine
 
Don't thank me...pay me

I accept payment, in Cash, Bank Transfer, Forum Votes, Musical Instruments, Squirel Pelt and Sofa Cleaner...and at a push....cheques.


hehehe
No problem dude

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top