[wix-users] Stopping an application during uninstallation

Christian Worm Mortensen opensource at epust.dk
Thu Jul 15 05:40:57 PDT 2021


Hi!

I have made an MSI installer with WiX which installs a service and a
simple UI application.

I see some very weird behaviour with regard to stopping programs
during uninstallation.

If the UI application is running when I uninstall, I get a dialog
where I can quit it. It has a text like "The following applications
should be closed before continuing the install". This seems to work
fine, if I select to close the UI it is closed

However, even though the UI closes I get an error:

  "The setup was únable to automatically close all requested applications (...)"

The funny thing is that if I instead *either* quit the UI application
before uninstall *OR* remove the service from my application, then I
do not get this error.

What is going on? I generated logs for the different cases and grepped
for "REPORT". On these logs there is also only an error in case there
is both a service and a UI application running:

With service, UI running on uninstall:
MSI (s) (F8:DC) [13:22:13:318]: RESTART MANAGER: Session opened.
MSI (s) (F8:DC) [13:22:14:282]: RESTART MANAGER: Detected that the
service xxxClient will be stopped due to a service control action
authored in the package before the files are updated. So, we will not
attempt to stop this service using Restart Manager
MSI (c) (70:40) [13:22:14:287]: RESTART MANAGER: Session opened.
MSI (s) (F8:DC) [13:22:16:310]: RESTART MANAGER: Failed to shut down
all applications in the service's session. Error: 350
MSI (c) (70:40) [13:22:16:317]: RESTART MANAGER: Successfully shut
down all applications that held files in use.
MSI (s) (F8:DC) [13:22:21:174]: RESTART MANAGER: The user chose to go
on with the installation, although a reboot will be required.
MSI (s) (F8:88) [13:22:26:317]: RESTART MANAGER: Previously shut down
applications have been restarted.
MSI (s) (F8:88) [13:22:26:320]: RESTART MANAGER: Session closed.
MSI (c) (70:40) [13:22:26:432]: RESTART MANAGER: Previously shut down
applications have been restarted.
MSI (c) (70:40) [13:22:26:435]: RESTART MANAGER: Session closed.

With service, UI NOT running on uninstall
MSI (s) (F8:C8) [13:24:21:848]: RESTART MANAGER: Session opened.
MSI (s) (F8:C8) [13:24:22:651]: RESTART MANAGER: Detected that the
service xxxClient will be stopped due to a service control action
authored in the package before the files are updated. So, we will not
attempt to stop this service using Restart Manager
MSI (s) (F8:88) [13:24:27:520]: RESTART MANAGER: Session closed.

Without service, UI running on uninstall
MSI (s) (F8:54) [13:28:33:507]: RESTART MANAGER: Session opened.
MSI (c) (34:68) [13:28:34:492]: RESTART MANAGER: Session opened.
MSI (s) (F8:54) [13:28:44:240]: RESTART MANAGER: Successfully shut
down all applications in the service's session that held files in use.
MSI (c) (34:68) [13:28:44:253]: RESTART MANAGER: Successfully shut
down all applications that held files in use.
MSI (s) (F8:88) [13:28:52:284]: RESTART MANAGER: Previously shut down
applications have been restarted.
MSI (s) (F8:88) [13:28:52:288]: RESTART MANAGER: Session closed.
MSI (c) (34:68) [13:28:52:457]: RESTART MANAGER: Previously shut down
applications have been restarted.
MSI (c) (34:68) [13:28:52:470]: RESTART MANAGER: Session closed.

Without service, UI NOT running on uninstall
MSI (s) (F8:34) [13:30:29:971]: RESTART MANAGER: Session opened.
MSI (s) (F8:88) [13:30:35:653]: RESTART MANAGER: Session closed.

The UI and the service do not communicate at all. In fact, the UI is
just a default application created by Visual Studio and not modified.

I have an additional question:

I would prefer that the user is not even prompted to close the UI but
that it is just closed automatically during uninstall.

I have tried to use the WiX CloseApplication tag for that. Using that
does not prevent the dialog box above. How do I prevent that dialog so
that CloseApplication can close the UI instead?

Also, if I in the dialog above decide not to close the UI, it does not
seem to be closed by the CloseApplication tag. What have I done wrong?

It was a bit hard finding examples using the CloseDialog and I am very
new to WiX. Here is what I have done:

<InstallExecuteSequence>
  <Custom Action="WixCloseApplications" After="InstallInitialize" />
</InstallExecuteSequence>

<util:CloseApplication Target="[#XXXClientUI]" TerminateProcess="1"
RebootPrompt="no" CloseMessage="yes">
  <![CDATA[REMOVE="ALL" OR UPGRADINGPRODUCTCODE]]>
</util:CloseApplication> -->

Here is a log for an uninstall where I grepped for "close":

MSI (s) (E8:5C) [13:51:18:965]: Doing action: WixCloseApplications
Action start 13.51.18: WixCloseApplications.
MSI (s) (E8:30) [13:51:18:987]: Invoking remote custom action. DLL:
C:\WINDOWS\Installer\MSIEA1C.tmp, Entrypoint: WixCloseApplications
WixCloseApplications:  Entering WixCloseApplications in
C:\WINDOWS\Installer\MSIEA1C.tmp, version 3.11.4516.0
WixCloseApplications:  Checking App: C:\Program Files
(x86)\MyCompany\XXX Program\XXXClientUI.exe
MSI (s) (E8!70) [13:51:19:095]: PROPERTY CHANGE: Adding
WixCloseApplicationsDeferred property. Its value is 'C:\Program Files
(x86)\MyCompany\XXX Program\XXXClientUI.exe3350001'.
MSI (s) (E8!70) [13:51:19:098]: Doing action: WixCloseApplicationsDeferred
Action start 13.51.19: WixCloseApplicationsDeferred.
Action ended 13.51.19: WixCloseApplicationsDeferred. Return value 1.
Action ended 13.51.19: WixCloseApplications. Return value 1.
MSI (s) (E8:5C) [13:51:19:484]: Executing op:
ActionStart(Name=WixCloseApplicationsDeferred,,)
MSI (s) (E8:5C) [13:51:19:496]: Executing op:
CustomActionSchedule(Action=WixCloseApplicationsDeferred,ActionType=3073,Source=BinaryData,Target=WixCloseApplicationsDeferred,CustomActionData=C:\Program
Files (x86)\MyCompany\XXX Program\XXXClientUI.exe3350001)
MSI (s) (E8:94) [13:51:19:508]: Invoking remote custom action. DLL:
C:\WINDOWS\Installer\MSIEC22.tmp, Entrypoint:
WixCloseApplicationsDeferred
WixCloseApplicationsDeferred:  Entering WixCloseApplicationsDeferred
in C:\WINDOWS\Installer\MSIEC22.tmp, version 3.11.4516.0
WixCloseApplicationsDeferred:  Checking for App: C:\Program Files
(x86)\MyCompany\XXX Program\XXXClientUI.exe Attributes: 33
MSI (s) (E8:F8) [13:51:19:949]: RESTART MANAGER: Session closed.
MSI (c) (00:38) [13:51:20:045]: RESTART MANAGER: Session closed.

This installer did not contain a service, only a UI.

Best,

Christian


More information about the wix-users mailing list