SCRIPT: Kill a Process

TaskKill.EXE

Description: This tool is used to terminate tasks by process id (PID) or image name.

Parameter List: /S   system           Specifies the remote system to connect to.

/U   [domain\]user    Specifies the user context under which the command should execute.

/P   [password]       Specifies the password for the given user context. Prompts for input if omitted.

/FI  filter           Applies a filter to select a set of tasks. Allows "*" to be used. ex. imagename eq acme*

/PID processid        Specifies the PID of the process to be terminated. Use TaskList to get the PID.

/IM  imagename        Specifies the image name of the process to be terminated. Wildcard '*' can be used to specify all tasks or image names.

/T                    Terminates the specified process and any child processes which were started by it.

/F                    Specifies to forcefully terminate the process(es).

/?                    Displays help message.

Filters: Filter Name  Valid Operators           Valid Value(s) ---  ---           -    STATUS        eq, ne                    RUNNING | NOT RESPONDING | UNKNOWN IMAGENAME    eq, ne                    Image name PID          eq, ne, gt, lt, ge, le    PID value SESSION      eq, ne, gt, lt, ge, le    Session number. CPUTIME      eq, ne, gt, lt, ge, le    CPU time in the format of hh:mm:ss. hh - hours, mm - minutes, ss - seconds MEMUSAGE     eq, ne, gt, lt, ge, le    Memory usage in KB    USERNAME      eq, ne                    User name in [domain\]user format MODULES      eq, ne                    DLL name SERVICES     eq, ne                    Service name WINDOWTITLE  eq, ne                    Window title

NOTE 1) Wildcard '*' for /IM switch is accepted only when a filter is applied.   2) Termination of remote processes will always be done forcefully (/F). 3) "WINDOWTITLE" and "STATUS" filters are not considered when a remote      machine is specified.

TaskKill /F /IM notepad.exe TaskKill /F /IM notepad.exe /FI "WINDOWTITLE eq Users.txt - notepad"
 * Kill a Process by providing its name:
 * Kill a specific instance of the process, by providing the windows title value:

TaskKill /F /PID 5748
 * Kill a specific instance of the process, by providing the Process ID (PID):

that is included within the Windows 2000 Support tools
 * If you running on Win2K, Taskkill is not included with the windows, another nice tool to use is Kill.exe,

usage: KILL [options] < | >*

[options]: -f    Force process kill

This is the process id for the task to be killed. Use TLIST to get a              valid pid

The pattern can be a complete task name or a regular expression pattern to use as a match. Kill matches the supplied pattern against the task names and the window titles.