Search code examples
wixwindows-installer

WiX - Switch InstallScope from perUser to perMachine


I'm trying to create an installer that supports perUser and perMachine installations dependent on a selection of setup types on the UI.

  • The perUser setup type installs the application into "WIX_DIR_COMMON_DOCUMENTS" and shall require no admin permissions.
  • The perMachine setup type install the application into "ProgramFilesFolder" and shall request an UAC dialog.

My attempt was to initially set the Package/@InstallScope to perUser and then modify the ALLUSERS property later on.

If the user selects the perMachine setup type I'm trying to set the ALLUSERS property to 1 doing the following:

<Publish Property="ALLUSERS" Value="1">1</Publish>

The "Install" buttons gets an UAC icon, but no UAC dialog appears after I pressed it!

enter image description here

Instead I get an error message that I obviously have no privileges to install the application for all users of the machine.

Is it a bug that no UAC dialog appears or intended? Am I missing something?


Solution

  • Someone from the WiX Mailing list pointed me to the Single Package Authoring article on msdn.

    I had to initialize the following properties:

    <Property Id='ALLUSERS' Value='2' />
    <Property Id='MSIINSTALLPERUSER' Value='1' />
    

    and set the 'MSIINSTALLPERUSER' property to an empty string for a per-Machine installation.

    <Publish Property="MSIINSTALLPERUSER" Value="{}">1</Publish>
    

    Be aware that this only works for Windows Installer 5 and higher!