Page 1 of 1
Shutdown running applications
Posted: Mon May 20, 2013 9:31 am
by tofutim
Ideally, my installation asks the user to shut down browsers and Acrobat. We are currently doing through a dialog box in a program that InstallAware calls. However, I noticed that some users got really confused because the dialog got lost underneath some other windows. Is there a template for shutting down running applications where everything is integrated into the installer?
Re: Shutdown running applications
Posted: Mon May 20, 2013 10:35 am
by FrancescoT
Dear tofutim,
you could use "Terminate Process" command.
This command attempts a safe shutdown of a running application.
It works by calling the ExitProcess API from the context of the running application.
Regards
Re: Shutdown running applications
Posted: Mon May 20, 2013 10:44 am
by tofutim
Hi Francesco, thanks for your prompt reply. Indeed, I started experimenting with Terminate Process - Check for Process seems to work fine, but when I try to Terminate Process, the result is FALSE. (This is "Safely Terminate Process.) I do have a .NET application running, and the installer is Administrator, and the running process is on the user's account. Is this why it doesn't work? Is there a way to force it to work?
Re: Shutdown running applications
Posted: Mon May 20, 2013 11:01 am
by tofutim
Running taskkill does work. However it would be nice to "safely" terminate the program.
Re: Shutdown running applications
Posted: Mon May 20, 2013 11:10 am
by tofutim
Francesco, in my scenario, Safely Terminate Process and Terminate Program always fail, only taskkill kills the program. Again this is a .NET program. Do I need something in my program to handle the messaging?
Re: Shutdown running applications
Posted: Mon May 20, 2013 11:27 am
by tofutim
It turns out that if I set the Program Window Title Contains: to the exact window title, it does work. I was using a substring. Perhaps you mean "Program Window Title Is: (case sensitive, exact)". Once the program starts terminating, checking if it is running still shows that it is running (because the shutdown takes sometime). Is there an equivalent of Sleep so that I can check on a loop?
Re: Shutdown running applications
Posted: Mon May 20, 2013 11:34 am
by FrancescoT
Dear tofutim,
unfortunately, doesn't exist a 100% safe way to forcibly kill an app and it also depends, on which is the current process state of that application.
In fact when this happens (I'm sure you've you have noticed it many times), the caller should inform the user about the termination and then to proceed accordingly.
Please excuse me, but it is not clear to me if the process that you want to kill is running under te same user context.
Anyway, taskkill will brutally terminate the process even if not the case.
Alternatively, but this requires some work on your application, you could send a specific message to the running application in order to handle the request to terminate. I am not a c# expert, but by the following link it seems to be possible in NET as well.
http://www.richardhyland.com/diary/2009 ... plication/
Regards
Re: Shutdown running applications
Posted: Mon May 20, 2013 11:37 am
by FrancescoT
... see Sleep API function.
http://msdn.microsoft.com/en-us/library ... s.85).aspx
It can be easily called via "call DLL" command.
Regards
Re: Shutdown running applications
Posted: Mon May 20, 2013 12:51 pm
by tofutim
Yup that worked perfectly.
Finally, I need a dialog that says... stuff is running, I'm going to shut it down.
Re: Shutdown running applications
Posted: Mon May 20, 2013 2:56 pm
by tofutim
It seems that Terminate Program requires an exact Title - I have to close Adobe Reader, but the title of the document precedes Adobe Reader in the title so that "Terminate Program Adobe Reader" does not work. Any workarounds?