Tutorial Thursday

A couple of weeks we wrote up a tutorial on how to create a single batch file that would simultaneously launch several different applications. It’s a handy little trick that many people found useful because they are frequently running the same programs on their computer. For example, when you start your computer you might open a browser, media player, and document editor. Instead of clicking on each of those shortcuts individually you can create a single batch file that will do the dirty work.

In the comments of that article “ExitRitual” asked a great question. He was wondering if it would be possible to do the same thing, but for closing programs. This would come in handy if, for example, you were getting ready to play a computer game. Most people shutdown a majority of the running applications to ensure that the game runs smoothly, and it can all be done in a single batch file.

We’ve shown how to do something similar in the past, but we were using a free third-party program because it was a little more powerful for the task at hand. This time around we’re going to use a command line option that is built-in to Windows.


  1. Open Notepad (Start Menu -> Accessories -> Notepad):
  2. Now you need to find the filename of the programs you want to close. I believe the best way to do this is to open up the Task Manager. Do this by right-clicking on the Taskbar and choosing the Task Manager option. Then look for the filename of the program you want to close.
    Task Manager Image Name
  3. Now you’ll need to use the taskkill command in Notepad, along with the filename(s) that you just grabbed in the previous step. Each command will look like this:

    taskkill /im firefox.exe

    Where firefox.exe is the filename of the program you want to close. Put each of these commands on a separate line like this:
    Batch Close

  4. Save it as a .BAT file by manually entering in the extension at the end of the file name.
    Save Batch File
  5. Double-click on the new file that you just created to test out the results. Each program listed will be closed in a friendly fashion instead of being shutdown forcefully.

The batch file will be smart enough to skip over any applications that are currently not running. So throw all of those extra programs in the batch file, and don’t forget to include things that might be running the the System Tray.