taskkill
It is a very practical command line tool in the Windows operating system, mainly used to terminate one or more running processes.
The following is a detailed introduction to it:
Basic syntax
taskkill [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]
This command line tool can be used to end at least one process. The process can be ended based on the process id or image name (Image).
Common parameters and meanings
Related remote operation
/S system
: Specify the remote system to connect to.
/U [domain\]user
: Specify which user context should be executed in. If not specified, the current user will be used.
/P [password]
: Specify a password for the provided user account. If omitted, it will be prompted to enter.
Filter process related
/FI filter
: Filter the process to be terminated according to the specified conditions. Common filters areSTATUS
(Process status, such asRUNNING
)、IMAGENAME
(process image name) etc. For exampletaskkill /FI "STATUS eq RUNNING" /IM
Indicates that all running Notepad processes are terminated.
/PID processid
: Specifies the process ID of the process to be terminated. Each running process has a unique PID, which can be used through the Task Manager ortasklist
Command to view. For exampletaskkill /PID 1234
The process with PID 1234 will be terminated.
/IM imagename
: Specify the image name of the process to be terminated, that is, the name of the executable file corresponding to the process. Wildcards can be used*
,liketaskkill /IM notepad*.exe
All can be terminated tonotepad
The process corresponding to the executable file at the beginning.
Other operating parameters
/T
: Terminates the specified process and the child process initiated by it. For example, a parent process starts multiple child processes using/T
Parameters can terminate them together.
/F
: Forced terminate the process. Some processes may reject normal termination requests, using/F
Parameters can force end these processes, but may cause data loss because it does not give the process the opportunity to save data or perform cleanup operations.
/S system Specifies the remote system to connect to.
/U [domain\]user Specifies which user context should be in
Execute this command.
/P [password] Specify a password for the provided user context. If ignored, prompt for input.
/F Specifies the process to be forced to terminate.
/FI filter Specifies the task to filter into or out queries.
/PID process id Specifies the PID of the process to be terminated.
/IM image name Specifies the image name of the process to be terminated. The wildcard '*' can be used to specify all image names.
/T Tree kill: Terminates the specified process and any child processes started therefrom.
/? Show help/usage.
Example
Example of usage
Terminates the process with the specified image name
taskkill /IM
This command attempts to terminate all notepad processes normally. If the process does not respond to the normal termination request, you can add/F
Parameters:
taskkill /F /IM
Terminate the process according to PIDUse firsttasklist
The command checks the PID of a process. Assuming that the PID of a specific browser process is 5678, terminate it with the following command:
taskkill /F /PID 5678
Terminate the process and its child processesIf a service process starts multiple child processes and to terminate them all, you can use/T
Parameters, for example:
taskkill /F /T /IM
Test Close QQ Manager
# Test Close QQ Butler@echo off taskkill /f /t /im # Test to close "DingTalk"@echo off taskkill /f /t /im
Close a process and start the program
# Command line format@echo off start /d "D:\Program Files" File name # Example: Start "DingTalk"@echo off start /d "D:\My APP\DingTalk\DingDing\"
Things to note
- use
/F
Be careful when termination of the process by parameters, as it may result in loss of unsaved data or system instability. - Using remote operating parameters (
/S
、/U
、/P
) When ) , you need to ensure that you have the corresponding permissions and that the remote system allows remote management operations.
This is the article about the detailed explanation of the Windows CMD taskkill command (forced shutdown of the startup program). For more detailed explanation of the relevant taskkill command, please search for my previous article or continue browsing the related articles below. I hope everyone will support me in the future!