System wide environment variable? - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

csmart
Posts: 22
Joined: Tue Sep 22, 2009 7:49 am

System wide environment variable?

Howdy,

Is there a "nice" way to create an environment variable for all users, rather than just the local user who installs the software?

Currently if I set an environment variable under "Project Details -> Environment" this gets put under:

Code: Select all

HKEY_CURRENT_USER\Environment
I would have thought that the "Installation Type" setting under "Install Parameters" would define where the variable would be set.
If "Per-user" then set it for the current user only, but if "Per-machine" then system wide.

So, is there a way to make this set for all users, or should I just manually create a key using "Project Definition, Registry" under somewhere like:

Code: Select all

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
I'd prefer not to hard-code anything..

Thanks!
Chris
Last edited by csmart on Thu Oct 01, 2009 2:30 am, edited 2 times in total.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: System wide environment variable?

Hello,

On the Environment page, simply double click your environment variable entry from the list, and tick the "Windows NT/2000 system variable" so the variable can be installed as a system wide environment variable.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
csmart
Posts: 22
Joined: Tue Sep 22, 2009 7:49 am

Re: System wide environment variable?

Hey Gabriel,

Thank you, that does exactly what I want. I totally didn't see that option! Is it documented somewhere? I'm sorry to waste your time.

Edit: Not quite solved, see below.

Cheers,
Chris
Last edited by csmart on Thu Oct 01, 2009 2:31 am, edited 1 time in total.
csmart
Posts: 22
Joined: Tue Sep 22, 2009 7:49 am

Re: System wide environment variable?

Hi Gabriel,

Actually this hasn't really solved it nicely and has introduced another problem. When I install the software as a limited non-administrator user it (naturally) fails to create the environment variable (because it's system wide).

The variable is no longer created for the local user at all (makes sense because I told it to be a system variable) and after a reboot there is no variable set. I guess I could get around this by adding a second non-system variable for local users, this way non-admin users can ignore the error and while the system variable will fail, the local one should work.

However this doesn't seem an ideal solution and the installer will still throw that error message. To me, a better solution would be to utilise the "Installation Type" setting under "Install Parameters" where it will determine the user's privileges and acts accordingly.

This way if a user is not an administrator, the installer should create the environment variable under HKEY_CURRENT_USER.
If the user is an administrator however, then set it under HKEY_LOCAL_MACHINE.

This seems to me to be a much more clean solution. Would it be possible?

Thanks,
Chris
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: System wide environment variable?

Hello,

You can create two dummy components and two environment variables, a system and a per-user one. Tie each of the environment variables to one of the components. On the Organization page, select each of your components and condition them to either install or not depending on the value of the Privileged property.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”