WiX: how to make System property in Environment tag depend on installation scope (ALLUSERS)

StackOverflow https://stackoverflow.com/questions/7984521

  •  20-02-2021
  •  | 
  •  

Вопрос

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top