1

I use inno setup to setup my application. Before install, I will check the app is still running, and use taskkill command to kill the application force. But I find the tray icon will not disappear.

How to terminate the application gentlely or make the tray icon remove from the tray after kill?

Nick Sun
  • 141
  • 3
  • 10
  • Duplicate of [`this`](http://stackoverflow.com/q/25608445/960757) and [`this`](http://stackoverflow.com/q/26024720/960757). The solution for you is, do not use taskkill. Let your application create a mutex and use the `AppMutex` directive instead. – TLama Apr 21 '15 at 10:00
  • I want close the application automatically, not manually by user. If the AppMetux can do this? – Nick Sun Apr 21 '15 at 10:47
  • Nope, that's not what the `AppMutex` directive is for. – TLama Apr 21 '15 at 10:51
  • so,the question maybe changed to : how to close the application automatically and the application close properly. – Nick Sun Apr 21 '15 at 11:04
  • That was asked [`here`](http://stackoverflow.com/q/3507853/960757). – TLama Apr 21 '15 at 11:04

1 Answers1

3

I had the exact same problem, and fixed it with a simple change to my bat file and without having to install any other programs.

The problem was I was running taskkill with /f wich forces (hard) kills the task. If you kill it without the /f it sends a close signal to the application, the application exits cleanly and removes its system tray icon.

In my bat file I do two taskkill commands; the first without the /f and then again with the /f. If the first one works (which it usually should) then all is well and the system tray icon goes away. If for some reason the first one fails, the the second one will still kill it, although in that case the system tray icon would not be removed.

So, in my case, I use:
taskkill /t /im Memu*
taskkill /f /t /im Memu*

Works great :-)

rborchert
  • 146
  • 1
  • 6