cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
1Gunn1
Level 4

Adding system OR current user environment variable like HKEY_USER_SELECTABLE?

I want to add an environment variable to install with my application. I want it to install to the System area of the environment variables if the person doing the installation has administrative privileges. But if not, I want it to place the environment variable into the current User area. 


I can't figure out how to accomplish this easily?! In the Environment Variables view, when you add a variable, the only option for "Type" is "System" or "User". If I choose "System" and try to install as a normal user with privileges, I get an error during the installation process, near the end about not being able to add the environment variable. 

Doesn't it make sense to have an option like the registry has (and which I take advantage of) to place registry keys in HKEY_USER_SELECTABLE? That's easy!

If I'm overlooking something and there is an easy way, please let me know. 

Thanks,

0 Kudos
(1) Reply
ITSERVICES-PT
Level 3

You could make an install script where you set the environmental variables using Powershell, or package an MSI using Adminstudio where you also set registry keys to set variables at  the HKEY_CURRENT_USER\Environment  (user variables) or HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment (system variables)

0 Kudos