Wix's util:CloseApplication extension doesn't seem to work

Daniel Schaffer picture Daniel Schaffer · Jun 4, 2010 · Viewed 10.1k times · Source

I'm trying to close a process before uninstallation using Wix. I've confirmed that it works as long as there's a visible window, but if there isn't a visible window (which is the case most of the time with this app since it's a system tray app), the uninstaller just hangs, and eventually continues with the uninstallation, leaving the process running.

According to this forum post, it seems like Wix has had trouble closing minimized apps in the past, so I wonder if this is related?

Any suggestions as to what else I can do to make sure the process gets shut down? Is there any way I can try and capture the message in my app using the Win32 api maybe?

Here's the CloseApplication declaration:

<util:CloseApplication Id="CloseApp" CloseMessage="yes" Target="App.exe" RebootPrompt="yes" />

And here's the custom action:

<Custom Before="InstallInitialize" Action="WixCloseApplications">REMOVE = "ALL"</Custom>

Answer

Rob Mensching picture Rob Mensching · Feb 14, 2011

It looks like you are scheduling the WixCloseApplications custom action before the installation transaction. The way the custom action works, is it scheduled a deferred action that actually closes the applications. It can't do that work unless it happens during the transaction (After="InstallInitialize").

The fix is probably pretty easy. Remove the Custom/@Action="WixCloseApplications" element.