WiX: how to make System property in Environment tag depend on installation scope (ALLUSERS)
Вопрос
I'm writing my first WiX installer and I'd like to give user a choice during installation: install the program for all users or just for me.
I found that
- there is an InstallScopeDlg in wixlib that provides GUI for this
- magic
HKMU
in<RegistryValue Root='HKMU'>
is changed to either HKLM or HKCU depending on what scope was chosen
The last bit I need is to set environment variables properly.
Environment/@System
decides if the variable is set for one or for all users.
How can I make the System
property depend on the chosen installation scope?
Решение
You can author 2 different components, each containing a single Environment element: one with @System = 'yes', another with @System = 'no' (or just omitted). Conditions these components accordingly based on ALLUSERS property, so that the conditions are mutually exclusive. This way only one component is installed for each scope, and it will bring correct environment variable to the target machine.