tags:

views:

1891

answers:

3

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?

+1  A: 

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.

0xA3
Thanks for the answer! I tried it that way, but it doesn't work for me. According to the MSDN both dialogs are also shown only during installation and are not evaluated during uninstalling!
beef2k
Yeah, CloseApps probably needs a little beefing up to handle all these cases. It doesn't handle all scenarios, yet.
Rob Mensching
A: 

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.

sascha
A: 

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 Erlichmen