Shutdown running applications

Got a problem you cannot solve? Try here.
Post Reply
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Shutdown running applications

Post 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?
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Shutdown running applications

Post 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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Shutdown running applications

Post 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?
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Shutdown running applications

Post by tofutim »

Running taskkill does work. However it would be nice to "safely" terminate the program.
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Shutdown running applications

Post 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?
Attachments
2013-05-20_1027.png
2013-05-20_1027.png (11.4 KiB) Viewed 10171 times
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Shutdown running applications

Post 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?
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Shutdown running applications

Post 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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Shutdown running applications

Post 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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Shutdown running applications

Post by tofutim »

Yup that worked perfectly.

Finally, I need a dialog that says... stuff is running, I'm going to shut it down.
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Shutdown running applications

Post 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?
Post Reply