10

I'm in a kind of misery. I got an installer installing and starting a tray icon app (common .exe)

This is working properly, but now i want to stop that app before this UI telling the user to close the app manually comes up, because during the deinstall routine, my tray icon is removed but the process is still running.

I applied this custom action to close the app before uninstall (or even during)

<CustomAction Id="CloseTrayApp" ExeCommand="-exit" FileKey="TrayApp" Execute="immediate" Return="asyncNoWait" />

<InstallExecuteSequence>
    <Custom Action="CloseTrayApp" Before="InstallValidate" />
</InstallExecuteSequence>

But the "close all running apps" dialog still pops up, but i thought that this will solve my issue.

I already tried to use the CloseAction but i got into a hurry using it because of error while compiling the stuff. It says that the WixUtils namespace may be missing but i double checked that it is there:

xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"

How can I avoid the dialog window poping up and trigger this custom action to be executed?

quetzalcoatl
  • 32,194
  • 8
  • 68
  • 107
inva
  • 751
  • 2
  • 13
  • 28

1 Answers1

9

You also have to add a reference to WixUtilExtension.dll. If you are using Visual Studio / Votive you just right click add reference and select the DLL from [ProgramFilesFolder]Windows Installer XML v3.5\bin. Otherwise you have to make the extension available to the compiler and linker:

candle.exe yourfile.wxs -ext %full path to WixUtilExtension.dll%'
light.exe yourfile.wixobj -ext %full path to WixUtilExtension.dll% –out yourfile.msi yourfile.wixout'

More information can be found at:

Using Standard Custom Actions

Please note that the CloseApp custom action has a limitation that it won't "terminate" your application. It will only politely send your app a WM_CLOSE message and it's up to your trayapp to receive and process that message with a shutdown.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • Is there no other way using a custom action and pass an argument like "-exit" because my program reacts on that and terminates itself. I thought there might be something wrong with the before statement Before="InstallValidate". Can i hook up the deinstall routine in an earlier situation? – inva Mar 22 '12 at 13:39
  • I'm sorry, I read your description but not your code. Take a look at: http://wix.sourceforge.net/manual-wix3/util_xsd_closeapplication.htm – Christopher Painter Mar 22 '12 at 14:23
  • damn it's still not working properly... the tray icon becomes invisible but the tray app process is still running... :( what i'm doing wrong? I'm using following closeapp statement: – inva Mar 22 '12 at 15:26
  • the problem is probably in the tray app code. It has to subclass the WM_CLOSE message and terminate the app. It sounds like it closed the form but kept running. – Christopher Painter Mar 22 '12 at 15:48
  • 1
    The irony with a TrayApp is that I usually get the opposite behavior. If you terminate it the icon will stay in the tray until you mouse over it and then go away despite the process being long gone from task manager.+ – Christopher Painter Mar 22 '12 at 15:49
  • Actually you are right, but I can't finde sample code how to handle the WM_CLOSE event send by "util:CloseApplication", I tried overriding OnMainFormClosed() but it seems that the wm_close does not results in calling this event/handler method. Any suggestions how to implement handling the WM_CLOSE ? – inva Mar 22 '12 at 15:55
  • I've never written a trayapp. My googling suggests that the wm_close minimizes the tray app to the tray. I'd put a messagebox in the minimize event and see if that gets triggered. Maybe I'll have some time to try writing my first tray app and see if I can figure it out but usually I'm looking at problems like this from the outside as an installer guy. – Christopher Painter Mar 22 '12 at 15:59
  • the answer from scottm in the following link might be relevant. Just quit instead. http://stackoverflow.com/questions/937792/send-to-tray-on-close – Christopher Painter Mar 22 '12 at 17:35
  • Thanks Christopher for that link too, but actually this does not apply to my situation, no I'm back on the installer side and i'm asking myself if it might be possible to call my tray icon app right before any install validation dialog poping up telling the user to manualy close desired application and pass a parameter like "-exit" to it. My program can react on that call and i'm not enchained any more on that windows message routine ... because this freaks me out =/ – inva Mar 23 '12 at 08:12