Question

I am using Windows Installer XML 3.0 (WIX3) to install some software.

Everything works fine, however, I'm having a really hard time to handle the following use case: the installed software is still running, when the user tries to uninstall it. The default behavior seems to remove all files but lets the application running (which is hard to see in my case, because it's sitting in the task tray).

I added the following code in my installer.wxs file:

<InstallExecuteSequence>
  <Custom Action="WixCloseApplications" Before="RemoveFiles" />
</InstallExecuteSequence>

<util:CloseApplication Id="CloseFoobar"
                       CloseMessage="no"
                       Description="FooBar is still running!"
                       ElevatedCloseMessage="no"
                       RebootPrompt="no"
                       Target="foobar.exe" />

But this doesn't work - even worse, it shows a dialog that asks for a reboot during install!

What would be the correct way to do it?

Was it helpful?

Solution

As far as I remember it should be enough to add the following references to your UI:

<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />

The CloseApplication stuff is only for closing applications during install, but it is buggy (at least when I tried it some months ago, maybe it's fixed now?)

Unfortunately, this is again an example for the very poor documentation of WiX, not even standard install/uninstall scenarios like this one are documented.

OTHER TIPS

There was a similar question asked on the wix-users mailing list a couple of days ago. The answer given there was:

This is the way that Windows works pre-Vista and Restart Manager. There has to be a top-level window available. An app in the tray doesn't count.

There are a few threads on the topic in the wix-users archive as well.

for an example how to use closeapplication, follow this link: wix github project, unit tests

To show a prompt dialog you can use: <util:CloseApplication Id="CloseIE" Target="iexplore.exe" PromptToContinue="yes" Description="Test" />

Can you check the uninstall logs (here is how to enable them), as far as I remember Windows Installer will put your files in a delete pending state and ask for a reboot at the end.
Also you can write a simple custom action that will kill your process.

Shay's answer is correct. Recent versions of Windows Installer just behave this way. Windows Installer goes to a lot of trouble to make sure that you can avoid a reboot at uninstall time by re-mapping in-use Dlls etc. In general, a running app can continue running after uninstall, and some cleanup will occur when the app shuts down, the rest after the next reboot. The point is that if Windows Installer can move the in-use binaries to another location, keep any apps running, and replace the ones that were in use (but memory backing remapped) and all that's required is deleting a bit of non-essential junk at the next reboot then why force a reboot? There is no need to show a files-in-use dialog, so that situation doesn't arise.

This can cause issues if the app tries to access a file that's been uninstalled, but I assume that risk is seen as low. If the app needs to know that an uninstall is going on then intergrating with Restart Manager should work - Windows will tell it there's an uninstall going on. Otherwise again, Shay is correct. Write an uninstall custom action if necessary to tell the app to close down.

I also faced this problem. Changing the Before attribute to "InstallValidate" worked for me.

<Custom Before="InstallValidate" Action="WixCloseApplications"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top