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

How To Create Sys Env Var Programmatically?

Status
Not open for further replies.

Spoodles

Programmer
Nov 12, 2004
2
US
I believe there is NT documentation that claims this is not possible. I find that hard to believe.

Anyone ever found a way to create a true system environment variable, ie, not a user var or a process var, programmatically?

Thanks.
 
Course you can create them. It requires writing to the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and then broadcasting a WM_SETTINGCHANGE message.

However, note that the new (or altered) system environment variable is not retroactive, i.e the new/altered value will only appear in processes launched after the change is made
 
See thread713-939533

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top