跳到正文
Windows

Taskkill: Stop Windows Processes from the Command Line

taskkill /im notepad.exe /f ends a process by name; taskkill /pid 1234 /t /f ends a process and its children. Use tasklist first to find names and PIDs.

测试环境 Windows 11 24H2, Windows Server 2019

taskkill ends running processes from the command line. It’s faster than Task Manager when an app is frozen, it works in scripts, and it can stop processes on another computer on your network.

Find the process first

Command Prompt
tasklistntasklist /fi u0022imagename eq chrome.exeu0022

Syntax

Syntax
taskkill [/s Computer [/u Domainu005cUser [/p Password]]] [/fi Filter] [/pid ProcessID | /im ImageName] [/t] [/f]
OptionMeaning
/imImage (executable) name, e.g. notepad.exe. Wildcards like note* work.
/pidProcess ID from tasklist or Task Manager.
/fForce – end the process immediately, without letting it save.
/tTree – also end child processes it started.
/fiFilter, e.g. by status, user, memory or window title.
/s /u /pTarget a remote computer, optionally with other credentials.

Everyday examples

Command Prompt
rem End Notepad, forcefullyntaskkill /im notepad.exe /fnnrem End a process and everything it startedntaskkill /pid 4120 /t /fnnrem End every app that is u0022Not Respondingu0022ntaskkill /fi u0022status eq not respondingu0022 /fnnrem End a user's Excel on a remote PCntaskkill /s PC-042 /u CORPu005cadmin /im excel.exe /f

Useful filters

FilterExample
Status/fi "status eq not responding"
User/fi "username eq CORPjsmith"
Memory (KB)/fi "memusage gt 500000"
Window title/fi "windowtitle eq Untitled*"
Service/fi "services eq spooler"

Use /f with care

Forced termination skips “do you want to save?” prompts, so unsaved work is lost. Never end system processes such as csrss.exe, wininit.exe or lsass.exe – Windows will crash. Ending processes owned by other users or services needs an administrator prompt.

In PowerShell the equivalent is Stop-Process -Name notepad -Force or Stop-Process -Id 4120.

Inder Kochar

作者

Inder Kochar

系统与网络工程师 – 我把为客户使用的解决方案整理成文,并在真实系统上测试过。遇到类似问题了吗?

继续阅读

提出问题或分享您的解决方法

您的邮箱不会公开。评论需经审核——请围绕主题发言。