New WiX feature: Setting package installation scope

For flexibility at deployment time, MSI uses the value of the ALLUSERS property in determining the type of an installation—whether it’s per-machine or per-user. That lets a network administrator easily control whether the package’s shortcuts (for example) show up for all users or just one. There’s also the it-looks-good-at-first idea of ALLUSERS=2, which theoretically lets a package adapt to either an admin or non-admin user.

Problem is, in the era of UAC, a genuine per-user package wouldn’t require a prompt for elevation. Unfortunately, most “per-user” packages still need admin rights, because they still install to per-machine locations, like ProgramFilesFolder on the file system and HKEY_LOCAL_MACHINE in the registry.

To avoid lots of mysteriously failing packages, MSI 4.0 and later require packages to opt in as not requiring UAC elevation prompts. In WiX, that’s expressed by setting the Package/@InstallPrivileges attribute to limited. Confusingly, the default for ALLUSERS is null, which means to install the package per-user, so to get a per-machine package, you have to remember to instead set ALLUSERS to 1.

It’s easy enough to forget that, so I added the InstallScope attribute to the Package element to centralize the per-machine/per-user choice:

perMachine
Set this value to declare that the package is a per-machine installation and requires elevated privileges to install. Sets the ALLUSERS property to 1.
perUser
Set this value to declare that the package is a per-user installation and does not require elevated privileges to install. Sets the package’s InstallPrivileges attribute to “limited.”

This attribute doesn’t deprecate InstallPrivileges and you can use both (though it’s redundant to do so). If you specify perMachine, you must remove any Property element that sets ALLUSERS.

Posted in WiX at April 1st, 2008. Trackback URI: trackback
Tags: ,

5 Responses to “New WiX feature: Setting package installation scope”

  1. April 19th, 2008 at 22:26 #Joy of Setup » Highlights of WiX v3.0.4014.0

    [...] Added Package/@InstallScope. [...]

  2. May 6th, 2008 at 10:25 #VEERENDRA N

    Hi,

    We have a pecuiliar situation for the installation of our product, we need the msi to be setup in such a way that
    1. if the user is not having admin rights then the msi should automaticalle put the registry entries in HKCU
    2. If the user is having admin rights then msi will be setup permachine. using HKLM

    now my thoughts are to have a variable parameter like $REGROOT and pass on HKCU or HKLM for the reg root. I am finding difficult to get the syntax to pass the parameter inside the wxs file. is this the right way of doing this or any other way is preffered?

    thanks in advance

  3. May 6th, 2008 at 10:39 #Bob Arnson

    Use the registry root HKMU — it automatically adjusts based on whether the install is per-machine or per-user.

  4. May 7th, 2008 at 02:08 #VEERENDRA N

    thanks bob,

    will the installer skip the fact that the user is not having admin rights and go ahead and install in HKCU when we have HKMU as the root

    thanks
    viren

  5. May 7th, 2008 at 07:03 #Bob Arnson

    It’s automatic based on the value of the ALLUSERS property. You need to set that to switch between per-user and per-machine installs.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>