Taskkill is a Windows command-line tool used to terminate running processes by Process ID (PID) or image name (executable name). It functions similarly to ending a task in Task Manager but from the command line, offering more automation and scripting capabilities.
Key Syntax and Options
taskkill /PID <processid>: Terminates a process using its unique Process ID. Usetasklistto find the PID.taskkill /IM <imagename>: Terminates a process by its image name (e.g.,notepad.exe,chrome.exe). Wildcards like*can be used (e.g.,taskkill /IM *.exe)./F: Forces the termination of a process, especially useful for unresponsive applications./T: Terminates the specified process and any child processes started by it (a "tree kill")./FI "filter": Applies filters to select processes (e.g.,taskkill /FI "STATUS eq NOT RESPONDING"to kill all frozen apps).
Example Commands
Forcefully close Notepad:
taskkill /IM notepad.exe /FKill a process by PID (e.g., PID 1234):
taskkill /PID 1234 /FEnd all child processes of a parent (e.g., browser tabs):
taskkill /IM chrome.exe /F /TClose all non-responsive programs:
taskkill /FI "STATUS eq NOT RESPONDING" /F
Advanced Use
Remote termination: Use
/S systemto target a remote machine (e.g.,taskkill /S 192.168.1.100 /U admin /P password /IM notepad.exe).PowerShell equivalent: Use
Stop-Processfor similar functionality with better object-based scripting.
⚠️ Caution: Forcing process termination may result in unsaved data loss or system instability. Use
/Fonly when necessary.
you must kill child process too if any spawned to kill successfully your process
taskkill /IM "process_name" /T /F
/T = kills child process
/F = forceful termination of your process
Answer from aaa on Stack OverflowCMD what does /im (taskkill)? - Stack Overflow
what does taskkill /f /IM explorer.exe do?
Really killing a process in Windows - Stack Overflow
Using Command prompt to kill a task and start a task; machine doesn't recognize?
Videos
you must kill child process too if any spawned to kill successfully your process
taskkill /IM "process_name" /T /F
/T = kills child process
/F = forceful termination of your process
The taskkill and powershell (kill) methods didn't work for me; it still said "Access Denied".
I had better luck with this:
wmic process where "name='myprocessname.exe'" delete
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.
it allows you to kill a task based on the image name like taskkill /im iexplore.exe or taskkill /im notepad.exe
"End Process" on the Processes-Tab calls TerminateProcess which is the most ultimate way Windows knows to kill a process.
If it doesn't go away, it's currently locked waiting on some kernel resource (probably a buggy driver) and there is nothing (short of a reboot) you could do to make the process go away.
Have a look at this blog-entry from wayback when: http://blogs.technet.com/markrussinovich/archive/2005/08/17/unkillable-processes.aspx
Unix based systems like Linux also have that problem where processes could survive a kill -9 if they are in what's known as "Uninterruptible sleep" (shown by top and ps as state D) at which point the processes sleep so well that they can't process incoming signals (which is what kill does - sending signals).
Normally, Uninterruptible sleep should not last long, but as under Windows, broken drivers or broken userpace programs (vfork without exec) can end up sleeping in D forever.
taskkill /im myprocess.exe /f
The "/f" is for "force". If you know the PID, then you can specify that, as in:
taskkill /pid 1234 /f
Lots of other options are possible, just type taskkill /? for all of them. The "/t" option kills a process and any child processes; that may be useful to you.
Try this: wmic process where “name=‘myprocessname.exe’” delete
If you get an error with that too the see this:
I have a script that kills a specific task. It has stopped running. When I manually type the command TASKKILL /F /IM “notepad.exe” I get error initialization failure. This script works on all other 2003 and 2008 servers. I am not actually trying to kill notepad that is just an example. It won’t work if typed in manually.
So, this one has me pretty stumped. I’m pretty sure I’m doing everything right here, which is why I’m stumped, but that’s also why I’m coming to the experts for help!
I have a user who wants to have a script autorun at 3am daily, which will kill the current kiosk-style PowerPoint that is running, and then re-open the file with Powerpoint - doing this because the file has been updated in the meantime, so it will open a new file for the next day.
The machine running the kiosk display is a woefully outdated windows Vista Machine. Not sure if that will affect cmd syntax of commands.
Anyway, here is my current script in a *.bat file:
@echo off
taskkill /IM PPTVIEW.exe /t /f
start PPTVIEW.exe “S:[File-Path]\Run Daily.ppsx”
And that’s it. everything I know about *.bat files says that this should work just fine. And it does, on my personal Windows 10 machine in the office. But it doesn’t run on the Windows Vista; it gives the “invalid namespace” error in cmd, and also a dialog box that says “Windows cannot find PPTVIEW.exe”.
I double checked that the task was running in task manager and that I had the right name, and I do. Furthermore, I was able to use Powershell to “Stop-Process -Name PPTVIEW -Force”, without issue.
I’ve tried giving cmd the exact file-path of PPTVIEW in the start command as well, but it still claimed it couldn’t find it. So the problem is somewhat two-fold; the machine can’t find the process to terminate it, and also cannot find the process to start it again.
So I am making an HTML file which will kill all process on your computer and shutdown. I've linked an image to a .bat which has shutdown /s. I can't find any code on the web that kills all tasks running on the computer at once. Does any command exist that does this?
I had a similar problem with multiple instances of conhost.exe that I could not terminate with taskkill, even giving the exact pid. I always got the same error, saying that there are no instances of the task.
So I did what Pimp Juice IT suggested in a comment above using the following command, which successfully killed all conhost.exe at once.
wmic process where name="conhost.exe" call terminate
If the process was started from Visual Studio, it's possible that the debugger crashed, but VS still somehow has an attachment to the process, keeping it from being able to be killed. Just shutting down Visual Studio will also shut down the rogue process, in this case.
Essentially I want a command in which will open .exe files yet I do not know what I should be using presently. I have nothing else in mind.
Harm to the hardware by taskkill seem very improbable to me.
Harm to Windows is only possible if you use it to kill a Windows component that works in cooperation with other components, but you need to be really unlucky. Normally, killing a Windows component will only cause the tasks that it does to become unavailable. Killing a vital process will usually cause Windows to immediately reboot.
There is a big difference when using the /f switch or not. Using the
switch will cause the immediate termination of the process (unless
it's stuck in a kernel call that can't be terminated forcefully).
Without /f, taskkill will politely send the task a message that it
needs to terminate, same as clicking the X on the title bar.
Normally this should be tried first, since the
task will then shutdown in an orderly manner and without data loss.
Only if this fails should /f be used.
Both taskkill (WM_CLOSE signal) and Alt + F4, also any other ways to interrupt and close processes can cause harm either to your software or system.
It all depends on how the closed process handles interruption. One app could handle Alt + F4 not fully properly and e.g. result in its config not saved correctly. I'd say that's rare nowadays with all the frameworks in use and what not, but it happened to me in the past, e.g. with the example you also provided - a game starting to save right after I pressed Alt + F4, which I guess it registered after the fact. Save file got corrupted.
And of course taskkill /f (TerminateProcess) can cause more harm than the other alternatives as it skips some implemented security measures. Especially low level, e.g. system-related, processes could cause a lot of issues when forced to close.
I don't think this question is answerable in a general manner. I would just advise not to use taskkill in scripts unless you're sure it's safe - e.g. it can't damage any data or anything alike. Regular CLI/GUI apps that don't do I/O operations are the safest. Anything else - you might expect problems.
TLDR summary: it depends on the application/process, you should ensure nothing can go wrong, but it's likely to be safe most of the time nowadays.