Search code examples
wixwix3.11wix4

WiX: How to Upgrade "per user" installation including services


I have this product, build with WiX 3.11. It includes a service (note that there is no naming issue" involved like here or here):

<Component Id="fetcher_90_service_wrapper" Guid="ee31673b-1695-463c-896a-ef737ee206b8">
    <File Id="acme_fetcher_9_0_service.exe" Source="acme-wrapper\acme-fetcher-9_0-service.exe" DiskId='2' KeyPath='yes'/>

    <ServiceInstall ErrorControl='normal'
                    Name='acme-fetcher-9_0'
                    DisplayName="Acme 9.0 Fetcher"
                    Start='auto'
                    Type='ownProcess'
                    Account='NT Service\acme-fetcher-9_0'>

        <util:ServiceConfig
                FirstFailureActionType='restart'
                SecondFailureActionType='restart'
                ThirdFailureActionType='restart'
                RestartServiceDelayInSeconds='30'
                ResetPeriodInDays='1'/>

    </ServiceInstall>

    <ServiceControl Id="Fetcher90StartService" Start="install" Stop="both" Remove="uninstall" Name="acme-fetcher-9_0" Wait="yes"/>
</Component>

WiX decided for some reason (see my question here) to install this "per user". I did not configure it that way, as I just learned that this is a thing to take care of. The installer is shipped, the above cannot be undone.

Now I want to upgrade this installation, currently trying to use WiX 4.0.3. The service itself is unchanged. But WiX decided that the Upgrade installer now installs "per machine" – which fails to actually upgrade due to this limitation (it installs the new version besides the existing one):

If an application is installed in the per-user installation context, any major upgrade to the application must also be performed using the per-user context. If an application is installed in the per-machine installation context, any major upgrade to the application must also be performed using the per-machine context. The Windows Installer will not install major upgrades across installation context.

So I manually set the Package element to be installed per user again. But this installer does not even complete, as "per user" installations automatically run without "elevated privileges" (I tried perUserOrMachine as well), which disallows me to stop the service (even being my "own" service):

error message when trying to stop the service

What actually works: Starting the installer from an admin cmd - which seems kind of cumbersome for our customers. So I searched for a way to force a WiX 4 "per user" installation to run privileged – after all, the above mentioned documentation reads

Sets the package's InstallPrivileges attribute to "limited."

, so I just override InstallPrivileges, right? No, because that attribute is not only no longer documented, it's "eliminated". And as Windows decided to remove "Run as administrator": What's the WiX way to upgrade previously installed "per user" products?


Solution

  • The default install scope in WiX v3 was per-user. The WiX v3 templates all set the Package/@InstallScope='perMachine'. Based on feedback the default was changed in WiX v4 to per-machine.

    Elevated per-user is a very strange combination. It would not surprise me if WiX v4 prevented that sort of nonsense configuration to head off problems like this.

    The Windows Installer doesn't provide much help in this situation. I suppose I might ship a proper per-machine package and add a custom action to detect when upgrading from per-user and force the package to be per-user. That continues the odd per-user package that installs to per-machine locations behavior but it minimizes impact on the end-user.