34

I just read the following command:

taskkill /f /im something.exe

I read that /f forces the task to close, but what does /im do?

4
  • 12
    3 downvotes without anyone telling him why? Hans, you were downvoted here because you didn't do any research on the topic. As you can see in the answers, all you needed to do was a little bit of research and you would have found your answer. On SE it's expected you research before asking.
    – House
    Jan 24, 2014 at 21:44
  • Okay, I tried searching for it again even though I solved it and I was just searching under the wrong keyword!
    – Hans Peter
    Jan 24, 2014 at 21:50
  • 6
    @Michael 3 downvotes without anyone telling him why? Yes, I hate that. What do those people think it's going to achieve? It just scares new people away. Jul 10, 2018 at 6:23
  • @michaelhouse You are awesome, so is Paul Sanders. Oct 23, 2019 at 0:02

5 Answers 5

45

It tells taskkill that the next parameter something.exe is an image name, a.k.a executable name

C:\>taskkill /?

TASKKILL [/S system [/U username [/P [password]]]]
         { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]

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 this help message.
10
  • 1
    Thanks for the list, but now you make me feel uneasy if I should use /t too, for taskkilling the explorer.exe. Does it have child processes?
    – Hans Peter
    Jan 14, 2014 at 18:04
  • And if I kill a kill a task with task manager , which parameters are added?
    – Hans Peter
    Jan 14, 2014 at 18:05
  • Killing taskmgr with /T will not kill anything else unless you used TM's File > New Task option to run something. /T on explorer.exe is another story! Most likely anything you launched as a user is a child of explorer.exe
    – EkriirkE
    Jan 14, 2014 at 18:08
  • No, I mean when I open the task manager to kill a process, how is it killed?
    – Hans Peter
    Jan 14, 2014 at 18:11
  • 1
    End process would be /F, process tree would be /F /T. It force closes as can be seen by tying something in a blank notepad document. A normal close process would open the "Save?" prompt. A force close disregards anything the process may do for cleanup and simply terminates it. taskmgr likely uses the PID so as to not kill all instances of same-named executables, only the single instance in question.
    – EkriirkE
    Jan 14, 2014 at 18:11
8

it allows you to kill a task based on the image name like taskkill /im iexplore.exe or taskkill /im notepad.exe

2
  • 2
    This is the CORRECT answer, others just ignored the details about it.
    – user285594
    Sep 14, 2016 at 13:08
  • 3
    I think what some people wonder is "What the heck is an Image Name?" It's the exe name and extensiopn, sans the file path to the exe. Oct 24, 2019 at 16:39
6

If you type the executable name and a /? switch at the command line, there is typically help information available. Doing so with taskkill /? provides the following, for instance:

TASKKILL [/S system [/U username [/P [password]]]]
         { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]

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 this 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.

Examples:
    TASKKILL /IM notepad.exe
    TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
    TASKKILL /F /IM cmd.exe /T 
    TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
    TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
    TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
    TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"

You can also find this information, as well as documentation for most of the other command-line utilities, in the Microsoft TechNet Command-Line Reference

4

im is "image process name" example /f /im notepad.exe is specified to kill image process name (program) notepad.exe

1

See the doc : it will close all running tasks using the executable file something.exe, more or less like linux' killall

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.