命令提示符(Command Prompt)包含许多强大的实用程序,可以帮助您解决问题,甚至修复您的Windows安装。除了系统文件检查器(System File Checker)和Diskpart等常见的罪魁祸首之外,Taskkill命令对于任何Windows用户来说都是另一个有用的工具。
顾名思义,该命令可以杀死任务和进程,释放系统资源。它比其他类似方法(other similar methods)更有用,因为它具有多种过滤选项,允许聪明的用户设置自动杀戮列表,以防止不必要的程序占用内存。
为帮助您入门,这里简要介绍了如何在Windows 10或 11上使用Taskkill命令。
为什么需要使用Taskkill 命令(Taskkill Command)?
使用Taskkill命令并不是关闭Windows任务和进程的唯一方法。杀死进程最常用的方法是通过任务管理器(Task Manager)。
任务管理器(Task Manager)允许您查看所有正在运行的进程并只需单击几下即可结束任何进程。此方法易于使用,不需要您在黑色终端中费力地输入代码。那你为什么还要打扰Taskkill呢?
多功能性(Versatility)。如果您只想不时地杀死几个额外的进程,任务管理器(Task Manager)无疑是完成这项工作的最佳工具。但是,如果您希望每天结束大量进程,则需要一种具有更多自定义功能的方法。
使用Taskkill命令,可以根据特定的过滤器一次关闭整批进程。您甚至可以将某些命令设置为快捷方式,让您可以随时从桌面双击运行它们。
Taskkill 的基本语法
- 要直接使用Taskkill命令,我们首先需要打开Command Prompt(the Command Prompt)。只需在开始菜单中搜索cmd并选择(cmd)Run as Administrator即可。
- 要使用Taskkill命令终止进程,您需要它的名称或PID。输入tasklist将为您提供所有正在运行的进程的完整列表,以及它们的PID(PIDs)和内存使用情况。
- 您现在可以使用命令tasklist /IM “NAME” /F 来终止任何进程,其中 NAME 必须替换为您要结束的任务的实际名称。/F 参数强制进程终止,这对于许多不想关闭的讨厌任务很有用。
- 要改用 PID,请输入taskkill /IM PID /F,其中PID是上一个列表中进程的数值。结果是一样的。
使用带有过滤标志的 Taskkill
到目前为止,taskkill 命令似乎只是一种更复杂的方式来执行任务管理器(Task Manager)已经可以执行的操作。使用 tasklist 获取所有正在运行的进程的名称并手动定位每个进程是一种相当乏味的终止任务的方法。
但这不是使用 taskkill 的唯一方法。您可以使用许多过滤选项来自动查找特定类型的进程并杀死它们,而无需知道它们的名称或PID(PIDs)。
以下是可用于 taskkill 的所有过滤器:
- STATUS:基本上,进程的状态。可以是RUNNING、NOT RESPONDING或UNKNOWN。
- IMAGENAME:与任务列表相同的名称。
- PID:可以通过 tasklist 命令看到的数字 ID。
- 会话:(SESSION: )会话号。
- CPUTIME:进程使用(CPUTIME: )CPU的持续时间。它以标准的两位数小时:分钟:秒格式给出。
- MEMUSAGE:任务的内存使用量,以 KB 为单位。
- USERNAME:发起任务的用户帐户的名称。
- MODULES:进程正在使用的DLL的名称。
- SERVICES:对于与Windows服务关联的进程,这给出了服务的名称。
- WINDOWTITLE:正如它所说,进程窗口的标题。
其中一些过滤选项比其他过滤选项更有用。例如,您可以使用USERNAME选项关闭来自特定用户的进程,这对于管理联网计算机很有用。
这些过滤器中的大多数也可以与逻辑运算符结合使用。但不是使用数学符号,而是用实际短语的缩写来表示。例如,等于变成eq,不等于变成ne,大于变成gt ,等等。
为了演示,这里是结束所有没有响应的进程的命令:
taskkill /FI “STATUS eq NOT RESPONDING” /F。
必须包含/FI 标志才能使用任何过滤器,后跟包含过滤表达式的字符串。所有其他过滤选项都可以类似地使用,终止与设定条件匹配的进程。
使用文件快捷方式(File Shortcuts)创建Taskkill 应用程序(Taskkill Applications)
从命令提示符(Command Prompt)运行Taskkill命令并不是您可以使用该工具做的唯一事情。您可以将Taskkill命令绑定到桌面快捷方式以立即使用它。这允许您执行特定的杀戮列表,而无需打开 cmd 并在其中输入一堆文本。
- 要创建 taskkill 应用程序,请右键单击桌面上的任何空白区域,然后选择新建(New )>快捷方式。(Shortcut.)
- 现在在快捷方式的目标中,我们将输入 taskkill 命令,以 taskkill.exe 开头以允许它运行。使用我们在上一节中演示的相同命令,我们得到taskkill.exe /FI “STATUS eq NOT RESPONDING” /F。
- 只需使用您想要的任何名称保存此快捷方式,您就可以开始了。随时双击这个新创建的快捷方式可立即终止所有未响应的进程。(Double-click)
使用Taskkill 命令(Taskkill Command)清理系统内存(System Memory)
Taskkill命令是一次结束许多类似任务的绝妙方法,无需手动检查任务管理器中的每个单独(Taskkill)进程(Task Manager)。一开始使用它可能看起来有点令人生畏,但一旦你掌握了它,你会发现它相对容易使用。
大量的过滤选项使 Taskkill 成为一个强大而灵活的工具。它允许您根据参数终止进程,而不必根据自己的判断来确定单个任务。
更好的(Better)是,您可以轻松地将特定的 Taskkill(Taskkill)命令保存为桌面快捷方式。它们充当迷你应用程序,您可以毫不费力地立即杀死一类无用的进程。
How to Use the Taskkill Command in Windows 10/11
The Command Prompt is home to many powеrful utilities that can help you troubleshoоt problems or even fix your Windows installation. Along with the usual culprits like the System File Checker and Diskpart, the Taskkill command is another useful tool for any Windows user.
As the name suggests, the command can kill tasks and processes, freeing up system resources. It is more useful than other similar methods because of its versatile filtering options, allowing a clever user to set up automated kill lists to prevent unnecessary programs from hogging memory.
To get you started, here is a short primer on how to use the Taskkill command on Windows 10 or 11.
Why Do You Need to Use the Taskkill Command?
Using the Taskkill command isn’t the only way to shut down Windows tasks and processes. The most common way of killing a process is through the Task Manager.
The Task Manager allows you to view all running processes and end any process with a few clicks. This method is easy to use and doesn’t require you to painstakingly type in code in a black terminal. Why then should you even bother with Taskkill?
Versatility. If you only want to kill a couple of extra processes every now and then, the Task Manager is undoubtedly the best tool for the job. But if you wish to end a large number of processes daily, you need a method with a bit more customization.
With the Taskkill command, it is possible to shut down whole batches of processes at once, based on specific filters. You can even set up certain commands as shortcuts, allowing you to run them with a double-click from the desktop at any time.
The Basic Syntax of Taskkill
- To use the Taskkill command directly, we first need to open the Command Prompt. Simply search for cmd in the Start Menu and select Run as Administrator.
- To kill a process with the Taskkill command, you need its name or its PID. Entering tasklist will give you a complete list of all running processes, along with their PIDs and memory usage.
- You can now use the command tasklist /IM “NAME” /F to kill any process, where NAME has to be replaced with the actual name of the task you are looking to end. The /F parameter forces the process to terminate, which can be useful for many pesky tasks that don’t want to shut down.
- To use the PID instead, enter taskkill /IM PID /F, where PID is the numerical value of the process from the previous list. The results are the same.
Using Taskkill With Filtering Flags
So far, the taskkill command may just seem like a more convoluted way of doing what the Task Manager could already do. Using tasklist to get the names of all running processes and targeting each one manually is a rather tedious way of terminating a task.
But that’s not the only way to use taskkill. There are many filtering options you can use to automatically find particular types of processes and kill them without having to know their names or PIDs.
Here are all the filters available for use with taskkill:
- STATUS: Basically, the status of the process. Can be RUNNING, NOT RESPONDING, or UNKNOWN.
- IMAGENAME: The same names brought up by tasklist.
- PID: A numeric ID that can be seen through the tasklist command.
- SESSION: The session number.
- CPUTIME: The duration for which the process has been using the CPU. It’s given in the standard double-digit hours:minutes:seconds format.
- MEMUSAGE: The memory usage of the task in KB.
- USERNAME: The name of the user account from which the task has originated.
- MODULES: Name of the DLL being used by the process.
- SERVICES: For processes associated with Windows services, this gives the name of the service.
- WINDOWTITLE: As it says, the title of the process window.
Some of these filtering options are more useful than others. For example, you can use the USERNAME option to shut down processes from a particular user, which can be useful in managing networked computers.
Most of these filters can also be combined with logical operators. But instead of using mathematical symbols, they are denoted by contractions of the actual phrases. For example, equal to becomes eq, not equal to becomes ne, greater than becomes gt, and so on.
To demonstrate, here is the command to end all processes that are not responding:
taskkill /FI “STATUS eq NOT RESPONDING” /F.
The /FI flag must be included for using any filter, followed by a string containing the filtering expression. All other filtering options can be used similarly, terminating processes matching a set condition.
Creating Taskkill Applications With File Shortcuts
Running Taskkill commands from the Command Prompt isn’t the only thing you can do with the tool. You can bind a Taskkill command to a desktop shortcut to use it instantly as well. This allows you to execute a particular kill list without opening up cmd and entering a bunch of text in it.
- To create a taskkill app, right-click on any empty space on your desktop and select New > Shortcut.
- Now in the target for the shortcut, we’ll enter the taskkill command, prefaced by taskkill.exe to allow it to run. Using the same command we demonstrated in the previous section, we get taskkill.exe /FI “STATUS eq NOT RESPONDING” /F.
- Just save this shortcut with any name you want, and you’re good to go. Double-click on this newly created shortcut at any time to instantly terminate all not responding processes.
Clean-up System Memory With the Taskkill Command
The Taskkill command is a brilliant way to end many similar tasks at once without manually going over each individual process in the Task Manager. It might seem a bit daunting to use at first, but once you get the hang of it, you’ll find it relatively easy to work with.
The host of filtering options makes Taskkill a potent and flexible tool. It allows you to kill processes based on parameters rather than having to determine individual tasks on your own judgment.
Better yet, you can easily save specific Taskkill commands as desktop shortcuts. They act as mini-apps you can use without a hassle to kill a class of useless processes at once.