Buy the ARP T-Shirt! BIOS Optimization Guide Money Savers!
 
 01 March 2006
 N/A
  N/A
 Guides
 Dashken
 1.0
 Discuss here !
 112959
 
   
BIOS Option Of The Week - AGP to DRAM Prefetch
Since 1999, we have been developing the BIOS Optimization Guide, affectionately known... Read here
The Tech ARP 2014 Mega Giveaway Contest (Week 10)
We have been working hard to arrange a ton of prizes, which we will give away every w... Read here
   
Buy The BOG Book Subscribe To The BOG! Latest Money Savers!
The Task Killer In Windows XP
Digg! Reddit!Add to Reddit | Bookmark this article:

The Windows Taskkill Utility

Ever wished you could just end a few programs just by running a batch file? Or have you ever wanted to automatically end some programs according to a certain schedule?

Even if you Google, you won't be able to find a free software that will allow you to even do such simple tasks. But fret not, we will show you how to do it in this guide. And the best of all, this method is totally free of charge!

How can we do that? Well, that's because Windows XP has a built-in utility that allows you to do all the above for free!

This utility is called Taskkill. Most people will not have heard of it. It's designed to end one or more tasks or processes by killing the process ID or image name of the running program. Let us show you how to make use of it.

 

Creating A Taskkill Batch File

Take, for instance, a scenario where you want to automatically close several of your memory-hogging applications, just by executing a single batch file. This would be particularly useful when you want to play games that require a lot of memory or run a particularly memory-intensive application.

There's no need for you to manually close each application. All you need to do is run that batch file and those pre-selected applications will automatically be killed, freeing up memory for your game or application. Such a batch file would be a real time saver, wouldn't it?

Now, we will show you just how to do that with Taskkill. In this scenario, we will use Yahoo! Messenger and MSN Messenger as examples.

First, you need to identify the Image Names (or the running executable files) of both Yahoo! Messenger and MSN Messenger. You can do so by following these steps :

  1. Go to the Windows Task Manager by pressing Ctrl-Alt-Delete. Alternatively, you can right-click on your taskbar and select Task Manager from the menu.
     
  2. Then, click on the Processes tab. Here you will be shown all the current running processes on your computer.
     
  3. Now, look for the Image Names for Yahoo! Messenger and MSN Messenger. I've taken the liberty to highlight the two processes. The Image Name for Yahoo! Messenger is YPager.exe while the Image Name for MSN Messenger is msnmsgr.exe.
     
  4. After getting both Image Names, it's time to create that batch file. Fire up your Notepad (Start Menu > All Programs > Accessories > Notepad).
     
  5. Then type this commands in Notepad.

    @echo off
    taskkill /im YPager.exe /f
    taskkill /im msnmsgr.exe /f

The first line, @echo off, is optional. When echo is set to off, the subsequent commands are not shown on screen during their execution. You can opt not to include that line. It will not affect the execution of the batch file at all. Removing it will just allow you to see the commands being executed.

In the second and third lines of taskkill /im YPager.exe /f, the batch commands are broken down like this :

Taskkill - Executes the taskkill utility that's located at C:\Windows\system32\.
 
/im YPager.exe - Specifies the image name of the process (in this case, Yahoo! Messenger) to be terminated. Use the wildcard (*) to specify all image names (not recommended).
 
/im msnmsgr.exe
- Specifies the image name of the process (in this case, MSN Messenger) to be terminated. Use the wildcard (*) to specify all image names (not recommended).
 
/f
- Specifies that process(es) are to be forcefully terminated. This parameter is ignored for remote processes; all remote processes are forcefully terminated.

  1. Now, you can save the file as "taskkill.bat" (with the quotes). You can also use any file name you like, but remember to include the .bat extension.

There you have it. You have just created a batch file that you can execute (by double-clicking on it) to instantly kill off both Yahoo! Messenger and MSN Messenger.

Of course, you can add as many processes into the batch file as you need. Here's a copy of the batch file created.

Alternatively, you can substitute the Image Name for the PID or Process ID of the application. Here's an example :

@echo off
taskkill /pid 2452 /f
taskkill /pid 1480 /f

Using either the Image Name or the PID has the same effect. But you will probably prefer using the Image Name since it's easier to identify the process. But if there are more than ONE instance of the same Image Name in Windows Task Manager, then logically, using the Process ID would be better if we don't want to kill all instances of the same Image Name using just a single command.

 

Scheduling The Batch File's Execution

If you want the batch file to run at a specific time, you can do so by using the Task Scheduler. Just go to Start Menu > All Programs > Accessories > System Tools > Scheduled Tasks and click on the Add Scheduled Task to add a schedule for the batch file.

So, there you have it. You can now kill off a whole bunch of applications just by using a single batch file. And you can even do it without being present! Easy, isn't it?

But that's not all you can do with taskkill. Take a look at a few examples of the commands you can create with taskkill.

taskkill /pid 1230 /pid 1241 /pid 1253
taskkill /f /fi "USERNAME eq NT AUTHORITY\SYSTEM" /im notepad.exe
taskkill /s srvmain /f /im notepad.exe
taskkill /s srvmain /u maindom\hiropln /p p@ssW23 /fi "IMAGENAME eq note*" /im *
taskkill /s srvmain /u maindom\hiropln /fi "USERNAME ne NT*" /im *
taskkill /f /fi "PID ge 1000" /im *

If you want to create more complex commands like that, then you need to understand taskkill's syntax and parameters. Let's take a look.



 

 
   
Samsung EcoGreen F4 (HD204UI) 2 TB Hard Disk Drive Review
The Nikon D700 DX Crop Mode Guide
HTC Shift Mobile Computer Overview
Auzen X-Fi Prelude 7.1 Sound Card Review
NVIDIA GeForce 8600M GT Mobile GPU Review Rev. 2.0
Taskbar Shuffle Review
PC Power Management Guide Rev. 2.0
Christmas 2006 Gaming PC Buying Guide
Logitech Z-680 5.1 Speaker Set Review
Definitive Review of the Kensington Saddlebag Pro

 


Copyright © Tech ARP.com. All rights reserved.