Sunday, 11 November 2012

Taskkill Command

Hi Friends!

I apologize for not continuing with my BSOD article. The reason is quite hilarious: Last friday, one of my mates said that he feels like 'Neo'( from the Matrix series), when he sees himself working in comand prompt, like a scientist!!

He added, that, how easy it is to open programs from Run(Windows+R), if only, there could be such a short cut to kill a process using Run utility.

We all had a laugh as killing a process from task manager is the easiest method in the business, but, for people like him, there is a command - taskkill, which helps you to close any existing running program.

So lets get started.

taskkill(as the name suggest) kills one or more processes. The only hurdle is that it processes can be killed using process ID or image name(both could be known from Task Manager-> Processes tab)

The PID column is not visible by default, you need to select it from the list of columns to be shown in task manager. To make it visible, Click on View->Select Columns...


You will get another pop up, check all columns which you wish to see.

& PID is available to you.

Now, as we are equipped with both the parameters(though we need to know only one between them), we are ready to execute this command.

The syntax of the command is

taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t]

Let us now dissect the command one by one:

1. /s Computer specifies the name or IP address of the remote computer. Default: Local computer

2. /u Domain \User specifies account permissions of the specific user

3. /p Password specifies password for the account mentioned in 2.

4. /fi Filter Name: This is the protagonist of the story. It specifies the filters you can while executing your command. Using this you can apply filter on any column listed in task manager.

Eg:  taskkill /f /fi "USERNAME eq NT AUTHORITY\SYSTEM" /im devenv.exe

       taskkill /f /fi "PID ge 2000" /im *

 The keywords 'eq' -> 'equal to' , 'ge' -> 'greater than' are commonly used operators.

5. /pid ProcessID specifies the process id

6. /im ImageName: specifies the image name. Eg: notepad.exe, firefox.exe, iexplore.exe, devenv.exe, appleMobileServiceDevice.exe...

7. /f specifies that the process(es) should be terminated forcefully. Please note that all remote processes are killed forcefully; so this element is not much of use, when used for remote machine

8. /t: You might have seen when you right click on a process in task manager, you get two(among other options) options as Kill Process, below that Kill Process Tree. The -t element is for the second case. It species that all child processes should be killed along with the parent process.

One more example

    taskkill /f /im notepad.exe

Don't worry about remembering the image name for processes, with some practise, you will remember commonly used processes image name.

I hope now that my friend( and many other), could completely visualize themselves as Neo!

Rest is Next. Till then AdiĆ³s!



  

1 comment: