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

Set environment variable from VBScript

Status
Not open for further replies.

tvbruwae

Programmer
Aug 9, 2001
224
EU
Hi

I need a way to set a persistent user environment variable from VBScript (login script). After doing some research it looks to me like the best way is to write a value to the registry ("HKCU\Environment").

When using the RegWrite function I can write the key and then the variable appears in the list of user variables (My Computer-->Properties-->Advanced-->Environment Variables). So far so good..

However when I go to a command prompt and type "echo %myvariable%", the actual value is not returned. So it looks like the variable exists but is not loaded in memory. After logging off and on again, the echo works fine.

Does anyone know how I can load the persistent variable into memory as soon as the registry key is created? (Some sort of refresh function for variables)?

Cheers,
Tim
 
Hello tvb!

You should be able to do a search in this forumn for "environment variable" and find some useful information. Or, you can check out this FAQ
faq329-5755
which contains some info on environment variables.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top