Understanding MSI uninstall - EXECUTEACTION = INSTALL

587 views Asked by At

I'm having issues with with a custom action I want to run during uninstall. The custom action is responsible for unregistering a system level windows service.

Custom action:

     <CustomAction Id='UnregisterService'
    Directory='INSTALLDIR'
    ExeCommand='[INSTALLUTIL] /u &quot;/config=[INSTALLDIR]\configInstall.xml&quot;  &quot; ...
    Return='ignore'
    Execute='deferred' />

This action scheduled in the InstallExecuteSequence and should be invoked on uninstall and upgrade:

    <InstallExecuteSequence>
      <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
      <RemoveExistingProducts After="InstallValidate" />
      <Custom Action='UnregisterService' After='InstallFiles'>UPGRADEFOUND OR (Installed AND NOT UPGRADINGPRODUCTCODE)</Custom>
      <Custom Action='RemAgApps' After='UnregisterService'>UPGRADEFOUND OR  (Installed AND NOT UPGRADINGPRODUCTCODE)</Custom>
...
    </InstallExecuteSequence>

The problem is that when I run uninstall from the ARP, uregister action does not invoked (as written in msi logs):

Skipping action: UnregisterService (condition is false)

When I dig deeper into the log (which is terrible...) I see that there is no 'uninstall' action, only install:

Property(C): EXECUTEACTION = INSTALL
Property(C): ACTION = INSTALL
Product: BLABLA -- Installation completed successfully.MSI (c) (BC:50) [14:35:37:067]: Windows Installer installed the product. Product Name: BLABLA . Product Version: 5.1.0. Product Language: 1033. Manufacturer: BLABLA Team. Installation success or error status: 0.

My questions are :

  1. What is the flow of msi uninstall? (No couldn't find it in the web...)
  2. Why I get the 'Install' action during uninstall?
  3. How can I force uninstall to run my 'unregisterService' custom action?

Thanks!

1

There are 1 answers

2
Christopher Painter On

Custom actions should be avoided until you fully understand Windows Installer to avoid reinventing the wheel with a more fragile solution. To remove a service during uninstall you merely need:

<ServiceControl Id="myService" Name="MyService" Stop="both" Remove="uninstall"/>

Read this good article: InstallSite: Installation Phases and In-Script Execution

Windows installer installation transactions can take many forms. Initial install, repair, maintenance install, uninstall, upgrade, patch and so on. The installer tracks the state change of features, components and products at different levels so the concept of install/uninstall is more detailed.