4

As part of an WiX-based installer I have the following component with a User element (besides other components with File, ServiceInstall and ServiceControl elements):

<Component Id="cmpServiceUser" Directory="TARGETDIR" Guid="PUT-GUID-HERE">
    <util:User
      Id="ServiceUser"
      Name="[ProductName]"
      Password="[ServiceUserPassword]"
      PasswordNeverExpires="yes"
      LogonAsService="yes"
      CreateUser="yes"
      UpdateIfExists="yes"
      RemoveOnUninstall="yes"
    />
</Component>

I have decided to go the only-major-upgrades way and placed the following element inside the Product:

<MajorUpgrade
  Schedule="afterInstallInitialize"
  DowngradeErrorMessage="A newer version of [ProductName] is already installed."
/>

The first installation of the product works as expected. During a major upgrade, I would have expected the user to be first removed (during RemoveExistingProducts) and later being created again. But it behaves different: The user is really removed nearly at the end of the installation - after the service for example has been restarted again (Process Explorer can still tell me the service's user name but not the SID any more - as the service's user was removed after the service was started).

After many hours of dissecting various installation logs I have turned to peek into the sources of the UtilExtension and probably found an explanation in scauser.cpp (slightly reformatted for better SO-readability):

// Schedule the removal because the user exists and we don't have any flags set
// that say, don't remove the user on uninstall.
//
// Note: We can't rollback the removal of a user which is why RemoveUser is a
// commit CustomAction.

So I guess this late removal of the user really belongs to the RemoveExistingProducts action in this case.

Thanks for reading this far - now the question: Is it possible to use util:User@RemoveOnUninstall in collaboration with a major upgrade strategy?

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
CodeFox
  • 3,321
  • 1
  • 29
  • 41

0 Answers0