TaskKill: Kill process from command line (CMD)
We can kill a process from GUI using Task manager. If you want to do the same from command line., then taskkill is the command you are looking for. This command has got options to kill a task/process either by using the process id or by the image file name.
Kill a process using image name:
We can kill all the processes running a specific executable using the below command.
Example:
Kill all processes running mspaint.exe:
Kill a process forcibly
In some cases, we need to forcibly kill applications. For example, if we try to to kill Internet explorer with multiple tabs open, tasklist command would ask the user for confirmation. We would need to add /F flag to kill IE without asking for any user confirmation.
/F : to forcibly kill the process. If not used, in the above case it will prompt the user if the opened pages in tabs need to be saved.
To kill Windows explorer, the following command would work
The above command would make all GUI windows disappear. You can restart explorer by running ‘explorer’ from cmd.
Not using /F option, would send a terminate signal. In Windows 7, this throws up a shutdown dialog to the user.
Kill a process with process id:
We can use below command to kill a process using process id(pid).
Example:
Kill a process with pid 1234.
Kill processes consuming high amount of memory
For example, to kill processes consuming more than 100 MB memory, we can run the below command
More examples
Sometimes applications get into hung state when they are overloaded or if the system is running with low available memory. When we can’t get the application to usable state, and closing the application does not work, what we usually tend to do is kill the task/process. This can be simply done using taskkill command.
To kill Chrome browser from CMD
Kill Chromedirver from command line
To kill firefox browser application
To kill MS Word application(Don’t do this if you haven’t saved your work)
Sometimes, the command window itself might not be responding. You can open a new command window and kill all the command windows
This even kills the current command window from which you have triggered the command.
i have a question about this.
I have a process that runs in my domain that puts outlook suspended. As soon as I do a task kill forced as administrator it runs.
I wrote a little script, now i want to add admin rights to the script via GPO.
taskkill taskkill
Область применения: Windows Server (половина ежегодного канала), Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012 Applies to: Windows Server (Semi-Annual Channel), Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012
Завершает одну или несколько задач или процессов. Ends one or more tasks or processes. Процессы могут быть завершены по ИДЕНТИФИКАТОРу процесса или имени образа. Processes can be ended by process ID or image name. Команду tasklist можно использовать для определения идентификатора процесса (PID) процесса, который должен быть завершен. You can use the tasklist command command to determine the process ID (PID) for the process to be ended.
Эта команда заменяет средство Kill . This command replaces the kill tool.
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
ключ /s | Указывает имя или IP-адрес удаленного компьютера (не используйте символы обратной косой черты). Specifies the name or IP address of a remote computer (do not use backslashes). По умолчанию это локальный компьютер. The default is the local computer. |
/u \ /u \ | Выполняет команду с разрешениями учетной записи пользователя, заданного или пользователем \ . Runs the command with the account permissions of the user who is specified by or by \ . Параметр /u может быть указан только в том случае, если задано также значение /s . The /u parameter can be specified only if /s is also specified. По умолчанию заданы разрешения пользователя, который в данный момент вошел в систему компьютера, выполняющего команду. The default is the permissions of the user who is currently logged on to the computer that is issuing the command. |
/p |
Имена фильтров, операторы и значения Filter names, operators, and values
Имя фильтра Filter Name | Допустимые операторы Valid Operators | Допустимые значения Valid Value(s) |
---|---|---|
Состояние STATUS | eq, ne eq, ne | RUNNING | NOT RESPONDING | UNKNOWN |
IMAGENAME IMAGENAME | eq, ne eq, ne | Имя образа Image name |
ИД процесса PID | eq, ne, gt, lt, ge, le eq, ne, gt, lt, ge, le | Значение PID PID value |
SESSION SESSION | eq, ne, gt, lt, ge, le eq, ne, gt, lt, ge, le | Номер сеанса Session number |
CPUtime CPUtime | eq, ne, gt, lt, ge, le eq, ne, gt, lt, ge, le | Время ЦП в формате чч: мм: СС, где mm и SS находятся в диапазоне от 0 до 59, а чч — любое число без знака CPU time in the format HH:MM:SS, where MM and SS are between 0 and 59 and HH is any unsigned number |
мемусаже MEMUSAGE | eq, ne, gt, lt, ge, le eq, ne, gt, lt, ge, le | Использование памяти в КБ Memory usage in KB |
USERNAME USERNAME | eq, ne eq, ne | Любое допустимое имя пользователя ( или ) Any valid user name ( or ) |
Обслуживание SERVICES | eq, ne eq, ne | Имя службы Service name |
WINDOWTITLE WINDOWTITLE | eq, ne eq, ne | Заголовок окна Window title |
МОДУЛЕ MODULES | eq, ne eq, ne | Имя DLL DLL name |
Комментарии Remarks
Фильтры WINDOWTITLE и состояния не поддерживаются, если указана удаленная система. The WINDOWTITLE and STATUS filters aren’t supported when a remote system is specified.
Подстановочный знак ( * ) принимается для */im параметра, только если применяется фильтр. The wildcard character ( * ) is accepted for the */im option, only when a filter is applied.
Завершение удаленного процесса всегда выполняется принудительно независимо от того, задан ли параметр /f . Ending a remote process is always carried out forcefully, regardless whether the /f option is specified.
Указание имени компьютера для фильтра имени узла приводит к завершению работы и остановке всех процессов. Providing a computer name to the hostname filter causes a shutdown, stopping all processes.
Примеры Examples
Чтобы завершить процессы с идентификаторами 1230, 1241и 1253, введите: To end the processes with process IDs 1230, 1241, and 1253, type:
Чтобы принудительно завершить процесс Notepad.exe если он был запущен системой, введите: To forcefully end the process Notepad.exe if it was started by the system, type:
Чтобы завершить все процессы на удаленном компьютере срвмаин с именем образа, начинающимся с заметки, используя учетные данные для хироплнучетной записи пользователя, введите: To end all processes on the remote computer Srvmain with an image name beginning with note, while using the credentials for the user account Hiropln, type:
Чтобы завершить процесс с ИДЕНТИФИКАТОРом 2134 и любыми его дочерними процессами, но только в том случае, если эти процессы были запущены учетной записью администратора, введите: To end the process with the process ID 2134 and any child processes that it started, but only if those processes were started by the Administrator account, type:
Чтобы завершить все процессы с ИДЕНТИФИКАТОРом процесса, который больше или равен 1000, независимо от имен их образов, введите: To end all processes that have a process ID greater than or equal to 1000, regardless of their image names, type:
Windows: TaskKill — Убить Процесс по PID, Имени, Порту — CMD
Иногда приложение в Windows зависает и перестает отвечать, и тогда единственный способ его завершить — «убить» процесс из командной строки
Команда taskkill в Windows служит для завершения задач по имени или по идентификатору процесса (PID).
В этой заметке я показываю, как найти и убить процесс по его имени или по PID, а также как узнать какой процесс слушает порт.
Я также показываю, что делать в случае ошибок «Процесс не может быть прерван» и «Доступ запрещен».
Дельный Совет: Узнать код завершения команды/приложения! Читать далее →
Убить Процесс по Имени
Вывести список всех процессов в Windows и узнать полное имя процесса, который нужно убить (без учета регистра):
Убить процесс по имени:
Убить Процесс по PID
Вывести список всех процессов в Windows и узнать PID процесса, который нужно убить (без учета регистра):
Убить процесс по PID:
Убить Процесс на Порту
Вывести список всех процессов в Windows, слушающих TCP и UDP порты и узнать PID процесса, который слушает определенный порт:
Узнать имя процесса по его PID:
Убить процесс по имени или PID:
Дельный Совет: Аналог grep для CMD и PowerShell в Windows! Читать далее →
Возможные Ошибки
В случае появления следующей ошибки убейте процесс принудительно:
ОШИБКА: процесс с PID XXX не может быть прерван.
Причина: Данный процесс может быть прерван только насильственно с параметром /F.
При получении ошибки «Доступ запрещен», запустите командную строку от имени администратора:
ОШИБКА: процесс с PID XXX не может быть прерван.
Причина: Доступ запрещен.
Чтобы запустить CMD с правами администратора, нажмите клавишу Win , чтобы открыть меню «Пуск», наберите cmd , чтобы найти командную строку и нажмите комбинацию Ctrl + Shift + Enter , чтобы запустить командную строку от имени администратора.