Learn how to a build a cloud-first strategyRegister Now


Script to close an application

Posted on 2006-04-04
Medium Priority
Last Modified: 2012-06-27

I often forget to close an application before I "retire" for the evening.  One of my backup routines won't backup files that are still open.

Can someone please provide a script that will close a specific application with two options:
1) Force it closed (even if it prompts to save unsaved changes)
2) Don't force it closed (if it prompts to save unsaved changes, leave it alone until morning)

Question by:SAbboushi
LVL 85

Accepted Solution

oBdA earned 1000 total points
ID: 16378931
You can do that with a simple taskkill command:
taskkill /im application.exe /t /f
will close the program (/im, "image") named application.exe including child processes (/t, "tree kill") and force (/f) it to close.
taskkill /im application.exe
will just send the terminate signal to application.exe, whether and how it closes is up to the application (so if the application supports to ask for unsaved changes when exiting, it will ask, otherwise it will terminate).

Assisted Solution

marco_delpercio earned 1000 total points
ID: 16380751

Yes oBdA is right you can simply make a batch file to run taskkill but you CANNOT:

1) Use this batch file on systems different from XP Professional (XP home, 2000 or prior don't have the taskkill command)

2) Check wheter ANY application is asking for you to save or not because it's application dependent. Different applications use different saving policies there're programs like MS Word which will save a temporary copy after x minutes and then will ask you to save (in general many word processors act like this) or other applications like compilers or management or audio/video editing applications that will NOT save anything untill you specifically tell them to save. Moreover each application has its own way of implementation. Depending on the application it will save data in a file or a database (commit a transaction) or send data through network or print last data...it's very very variable. :-)

To just make a most portable version of the batch file oBdA suggested simply use the   pskill.exe   utility   downloadable from here: http://www.sysinternals.com/Utilities/PsKill.html

It works on many Win32 systems even non-XP and it works in a very similar way like taskkill. The functionality of the batch file and the way it should be made/used are just the same as oBdA told you...

Marco Del Percio


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question