Убейте все соответствующие процессы в Windows из командной строки

Всем известно, как убить процесс в Windows с помощью диспетчера задач.

Однако, когда вы находитесь в среде Terminal Server с 20-тью другими пользователями, и вам нужно убить все соответствующие процессы в Windows из командной строки, это просто невозможно, потому что может быть выполнено 100 процессов.

Но, вы можете использовать tasklist, чтобы перечислить все процессы Windows и taskkill, чтобы убить все соответствующие процессы в Windows из командной строки, похожие на kill или kill -9 в Linux.

Все это возможно с помощью команды TaskKill. Во-первых, давайте рассмотрим основы.

Вы можете убить процесс по идентификатору процесса (PID) или по имени образа (имя файла EXE).

Откройте командную строку административного уровня и запустите tasklist, чтобы просмотреть все запущенные процессы:

В приведенном выше примере вы можете увидеть имя образа и PID для каждого процесса.

Если вы хотите убить процесс запуска firefox:

Флаг / F убивает процесс принудительно.

Несоблюдение флага / F приведет к тому, что в некоторых случаях ничего не происходит.

Один из примеров – когда я хочу убить процесс explorer.exe, я должен использовать флаг / F, иначе процесс просто не завершится.

Если у вас есть несколько экземпляров открытого образа exe, например несколько процессов firefox.exe, запуск команды taskkill / IM firefox.exe приведет к уничтожению всех экземпляров.

Когда вы укажете PID, только конкретный экземпляр firefox будет прерван.

Реальная мощность taskkill – это параметры фильтрации, которые позволяют использовать следующие переменные и операторы.

Переменные

eq (equals)
ne (not equal)
gt (greater than)
lt (less than)
ge (greater than or equal)
le (less than or equal)

“*” is the wildcard.

Вы можете использовать переменные и операторы с флагом фильтрации / FI.

Например, предположим, что вы хотите завершить все процессы, у которых есть заголовок окна, начинающийся с «Internet»:

Как насчет убийства всех процессов, запущенных под учетной записью Steve:

Также можно убить процесс, выполняющийся на удаленном компьютере с taskkill.

Просто запустите следующую команду, чтобы убить notepad.exe на удаленном компьютере под названием SteveDesktop:

10 команд Windows, которые необходимо знать для устранения неполадок

Как завершить процесс в Windows

Формат командной строки:

Описание параметров командной строки :

/P пароль – Пароль для этого пользовательского контекста. Запрашивается, если он не задан.

/FI фильтр – Применение фильтра для выбора набора задач. Разрешение использовать “*”. Пример, imagename eq acme*

/PID процесс – Идентификатор процесса, который требуется завершить. Используйте TaskList, чтобы получить PID.

/IM образ – Имя образа процесса, который требуется завершить. Знак подстановки “*” может быть использован для указания всех заданий или имен образов.

/T – Завершение указанного процесса и всех его дочерних процессов.

/F – Принудительное завершение процесса.

/? – Вывод справки по использованию.

1) Символ ‘*’ для параметра /IM применим только совместно с фильтрами.

2) Завершение удаленных процессов всегда будет принудительным (/F).

3) Фильтры “WINDOWTITLE” и “STATUS” не принимаются во внимание, когда компьютер является удаленным.

Примеры использования TASKKILL.

TASKKILL /IM notepad.exe – завершить процесс, исполняемым образом которого является notepad.exe . Если таких
процессов более одного – то будут завершены все.

taskkill /PID 1234 /T – завершить процесс с идентификатором 1234 и все его дочерние процессы ( /T ) . Одной командой
можно завершить несколько процессов, задавая их PID – taskkill /PID 1234 /PID 2345 /PID 800. Для определения идентификатора
процессов используется команда tasklist :

notepad.exe        824 Console       1       3 916 КБ
notepad.exe      3004 Console       1      18 812 КБ
Где 824 и 3004 – это идентификаторы процессов PID

TASKKILL /F /FI “PID ge 2000” /FI “WINDOWTITLE eq Arc*” – принудительно (/F) завершить процесс, идентификатор которого
больше или равен 2000 и заголовок окна которого , начинается с текста Arc

При завершении процессов как локально, так и удаленно, результат выполнения команды TASKKILL зависит от прав пользователя,
в контексте учетной записи которого выполняется команда.

Для использования в многопользовательской конфигурации системы, например на сервере терминалов, вместо команды TASKKILL, удобнее и безопаснее
использовать команду TSKILL, адаптированную для завершения процессов в среде конкретных пользователей удаленного рабочего стола (RDP).

Весь список команд CMD Windows

  • Review the list. Review the task list to search for the program that you want to end. Look at the “Image Name” specifically, since you will need this information to kill the task.
    You will probably have to scroll down to review all of the processes, since they won’t fit all on one page.
  • You will probably have to scroll down to review all of the processes, since they won’t fit all on one page.
  • Kill the task. First, you need to type in taskkill. Then, you have to specify that you are killing the task based on its image name, so put in a space, and then type in /IM. After this, put in another space, and then type in the Image Name of the program that you want to end. For this example, notepad.exe will be the task that will be killed. Afterwards, press . This will kill the task.
    For this example, the whole command would look like taskkill /IM notepad.exe.
  • For this example, the whole command would look like taskkill /IM notepad.exe.
  • Type in tasklist. Just like the previous task, you need to type in tasklist to view the running programs, and to retrieve the image name.
  • Type in the regular taskkill command. You would first type in the command like your normally would. For example, to forcefully kill notepad.exe, you would type in taskkill /IM notepad.exe.
  • Add /F to the end of the command. The “/F” argument tells taskkill that you want to forcefully end the process. Keep in mind that you have to add a space before adding this argument.
  • Type in taskkill. This is the beginning of the command.
  • Type /FI “STATUS eq NOT RESPONDING”. This specifies that you want to kill all programs that are not responding. Remember that you need to add a space after taskkill.
  • Add /F to the end. Since non-responsive programs will not close on their own, they need to be forcefully closed. Then, press . This will end all non-responsive programs.
    Remember to add the space before typing /F.
  • Remember to add the space before typing /F.
:/>  Как активировать Windows 10? Способы активации Windows 10

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

  • The taskkill command is not case sensitive
  • There are many other things that taskkill can do, but most people will not need to use them. You can view all arguments for the taskkill command here.

Thanks for submitting a tip for review!

References

Thanks to all authors for creating a page that has been read 20,654 times.

When you start an app, the operating system creates a process for an executable file of the app. It contains the program code and its current activity. Windows assigns a special number known as Process Identifier (PID) which is unique for every process. There are a number of reasons you might want to kill a process, and different methods you can use to terminate it. Here is how it can be done.

If an app stops responding, consumes a lot of system resources or behaves unexpectedly and doesn’t allow you to quit it, you might want to kill its process to forcefully close the app. Traditionally, Windows allowed using Task Manager and the command prompt for these tasks. In addition to these methods, you can use PowerShell. Here is how.

  • Open Task Manager.
  • Click on “More details” in the bottom right corner to enter Full view mode.
  • Select the desired app in the app list.
  • Click on the End task button or hit the Del key on the keyboard.

You are done.

This is Task Manager’s most well known method.

Note: The same can be done from the Details tab. It is a special tab which lists process names instead of app names. There you can select a process in the list and either click on the End process button or hit the Del key.

Убейте все соответствующие процессы в Windows из командной строки

Using the End Task button means Windows first tries to see for a certain timeout if the process has really stopped responding, and attempts to collect a crash or memory dump of the process. It then terminates the app.

Tip: We highly recommend you read the article How to end a process quickly with Task Manager in Windows 10 to learn all Task Manager tricks. Also, you can get the classic Task Manager app in Windows 10 to end processes or tasks.

Another classic method to close a process is the console tool taskill. It comes bundled with modern versions of Windows.

Kill a process using Taskkill

  • To kill a process by its PID, type the command:taskkill /F /PID pid_number
  • To kill a process by its name, type the commandtaskkill /IM “process name” /F

For example, to kill a process by its PID:

Убейте все соответствующие процессы в Windows из командной строки

To kill a process by its name:

taskkill /IM “notepad.exe” /F

Kill a process using PowerShell

  • Type the command Get-Process to see the list of running processes.
  • To kill a process by its PID, run the command:Stop-Process -ID PID -Force

Examples: This command will close the notepad.exe process.

Stop-Process -Name “Notepad” -Force

Убейте все соответствующие процессы в Windows из командной строки

Stop-Process -ID 2137 -Force

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

Post navigation

On Windows, different processes are executed on different ports of TCP and UDP. Sometimes we need to access a certain port but cannot do so because another process is already using it. As a result, we must kill the process on that particular port. To stop particular processes, you can utilize the PID or port number.

This article will elaborate on the method to kill processes currently using a port on localhost in Windows:

  • Using Command Prompt
  • Using PowerShell
  • Using CurrPorts

Let’s get started!

Use Command Prompt to Kill the Windows Process Currently Using a Port on localhost

Step 1: Open Command Prompt

First, press the “Window+R” key to open the Run box. Type “cmd” in the dropdown menu and hit the “OK” button to open a command prompt:

Убейте все соответствующие процессы в Windows из командной строки

Step 2: Check the localhost Port Running Process

Utilize the “netstat” command to find out the currently running process on the localhost port:

Убейте все соответствующие процессы в Windows из командной строки

Step 3: Kill Process Using PID

Then, use the “taskkill” command and specify the PID of the process currently running on localhost and kill it:

Убейте все соответствующие процессы в Windows из командной строки

Step 4: Verify the Process State

Again run the “netstat” command to verify that the port on the localhost is running any process or not:

As no output is shown, which indicates that the specified process is killed successfully:

Убейте все соответствующие процессы в Windows из командной строки

Step 5: Kill Process by Specifying localhost Port

We have successfully terminated the process that is running using a port on localhost:

Убейте все соответствующие процессы в Windows из командной строки

Let’s check out the method to kill the Windows process currently using a port on localhost through PowerShell.

Use PowerShell to Kill the Windows Process Currently Using a Port on localhost

To kill the Windows process currently using the localhost port with the help of Powershell, utilize the below provided steps.

Step 1: Open Windows PowerShell

Убейте все соответствующие процессы в Windows из командной строки

Step 2: Find localhost Port Running any Process

Firstly, find any process that is currently using a port on localhost by executing the provided command:

Убейте все соответствующие процессы в Windows из командной строки

To terminate a process utilizing a localhost port, issue the “stop-process” command with the PID number:

Убейте все соответствующие процессы в Windows из командной строки

Step 4: Kill Process by Specifying localhost Port

Убейте все соответствующие процессы в Windows из командной строки

Run the “netstat” command once again to confirm that the specified process has killed:

:/>  Windows 10 снизить потребление оперативной памяти

Убейте все соответствующие процессы в Windows из командной строки

Now, let’s head towards the next section!

Step 1: Download CurrPorts

Visit the below-provided link and download the CurrPorts setup file:

Убейте все соответствующие процессы в Windows из командной строки

Step 2: Extract CurrPorts Setup Folder

Go to the “Downloads” directory and extract the zip folder. To do so, right-click on the file and choose the “Extract here” option:

Убейте все соответствующие процессы в Windows из командной строки

Step 3: Run CurrPorts Execution File

Double click on the file to run the “cports.exe” file:

Убейте все соответствующие процессы в Windows из командной строки

Select the port, then choose the “Kill Processes Of Selected Port” option from the context menu to kill the processes:

Убейте все соответствующие процессы в Windows из командной строки

We have effectively demonstrated the methods to kill the process currently using a port on localhost in Windows.

Conclusion

To kill the Windows process currently using a port on localhost, use the “npx kill-port 8000” command on Command Prompt. On Windows PowerShell, the “Get -process” command and the “Stop-process” command to find out and end the specified processes. Lastly, the CurrPorts tools can also be utilized for the same purpose. In this blog post, we have shown how to stop Windows processes that are currently using a port on localhost.

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.

Introduction

In this article, you will learn various ways to kill or force-quit a process/program.

Убейте все соответствующие процессы в Windows из командной строки

A program or application is made up of one or more processes. In its most basic form, a process is a running program. In the context of the process, one or more threads are running. The fundamental unit to which the operating system assigns processing time is a thread. A thread can run any portion of the process code, even bits that are presently being run by another thread.

Windows Program

A Windows-based application is a software that is intended to operate on computers that use the Microsoft Windows operating system. These applications are intended to be installed and operated locally on a Windows computer, and they are often compatible with many versions of Windows. Many Windows-based apps are incompatible with macOS, which is used on Apple computers, while the majority are incompatible with Linux-based machines.

Why kill a process?

  • Process may slow your computer.
  • Process may enter into an infinite loop due to circular waiting, which may cause the system to enter into a hang state.

To know more, visit.

Using Task Manager

Open task manager.

Windows 11 doesn’t have an option to open task manager from the taskbar unlike earlier versions, you can learn how to open Task Manager in Windows 11, here.

Убейте все соответствующие процессы в Windows из командной строки

Click on the “Processes” tab.

Select a process you want to kill, and perform one of the actions below.

  • Press the Delete key.
  • Click on the End task button.
  • Right-click on the process, and click on End task.

Убейте все соответствующие процессы в Windows из командной строки

Using Command Prompt

Open Command Prompt (Cmd).

In the command prompt, type “tasklist” and hit the “Enter” key. This program displays a list of all the processes that are presently active on your system.

Убейте все соответствующие процессы в Windows из командной строки

To Kill Process using Process/Image Name

taskkill /IM Process Name /F

For Example – To kill Notepad, run the command as, taskkill /IM notepad.exe /F, where /F is used to kill the process forcefully.

Убейте все соответствующие процессы в Windows из командной строки

taskkill /IM Process Name /IM Process Name /F

To kill the process using PID

For Example – To kill Notepad, run the command as, taskkill /PID 2404 /F, where /F is used to kill the process forcefully.

Убейте все соответствующие процессы в Windows из командной строки

taskkill /PID PID  /PID PID /F

To find the PID you can go to the Task Manager, you can right-click on the top, and select PID, as shown in the figure.

Убейте все соответствующие процессы в Windows из командной строки

Using Run Command (Windows+R)

From the Start menu, open the Run dialog box or you can Press the “Window + R” key to open the RUN window.

Убейте все соответствующие процессы в Windows из командной строки

For Example – To kill Notepad, run the command as, taskkill /PID 2404 /F, where /F is used to kill the process forcefully.

Убейте все соответствующие процессы в Windows из командной строки

Visit C# Corner to find answers to more such questions.

If you have any questions regarding any other technology do have a look at the C# Corner Technology Page.

Sometimes when an application in Windows hangs, freezes and stops responding the only way to terminate it is to kill from the command-line.

The taskkill command in Windows serves for terminating tasks by name or by process id (PID).

In this note i am showing how to find and kill a process by its name or by PID and how to identify a process by the listening port.

I am also showing how to troubleshoot “The process could not be terminated” and “Access denied” errors.

List all Windows processes and find the full name of a process to kill (case insensitive):

Kill the process by name:

Kill Process by PID

List all Windows processes and find the PID of a process to kill (case insensitive):

Kill the process by PID:

Kill Process by Port

List all Windows processes listening on TCP and UDP ports and find the PID of a process running on a specific port:

Find the name of a process by its PID:

Kill the process by name or by PID:

Troubleshooting

ERROR: The process with PID XXX could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).

ERROR: The process with PID XXX could not be terminated.
Reason: Access is denied

The program in execution state is termed a process. Similarly, a Windows service running background programs is referred to as the Window process. When too many processes operate simultaneously, it can cause the system to slow down; therefore, we occasionally need to kill the process. In Windows, you can kill a process using its unique PID(Process identifier) or Process Name.

In this study, we will talk about different methods to kill a process in Windows:

  • Using Task Manager
  • Using Command prompt
  • Using Windows PowerShell
:/>  Как убрать возможное ограничение скорости интернета в Windows 10

So, let’s begin!

Kill Process in Windows Using Task Manager

To kill the process using Task Manager in Windows, utilize the below-given steps.

Step 1: Open Task Manager

Firstly, search “Task Manager” in the “Startup” menu and open it:

Убейте все соответствующие процессы в Windows из командной строки

Step 2: Kill Process

Open the currently running processes from the “Processes” menu. Choose the process you want to end, then click the “End task” button. For instance, we are going to kill the “Adobe Acrobat Update Service”:

Убейте все соответствующие процессы в Windows из командной строки

As you can see, the selected process is now no more in the list, which indicates that we have successfully killed it:

Убейте все соответствующие процессы в Windows из командной строки

Let’s move toward the second method to kill the process using a command prompt.

Kill Process in Windows Using Command Prompt

To kill the process using a command prompt in Windows, use the below-listed steps.

In the “Startup” menu, type “CMD” to search the command prompt and open it:

Убейте все соответствующие процессы в Windows из командной строки

Step 2: Check Task List

Execute the “tasklist” command to list down the currently running processes along with additional information:

Убейте все соответствующие процессы в Windows из командной строки

Убейте все соответствующие процессы в Windows из командной строки

Step 3: Utilize Process/Image Name to Kill Process

To kill the process by specifying the Process or Image name, utilize the below-listed command:

taskkill IM audiodg.exe F

Убейте все соответствующие процессы в Windows из командной строки

Step 4: Utilize PID to Kill Process

Убейте все соответствующие процессы в Windows из командной строки

We have successfully terminated the process using the command prompt in Windows. Let’s move ahead to kill the process using Windows PowerShell.

Kill Process in Windows Using PowerShell

Убейте все соответствующие процессы в Windows из командной строки

If the process is running on a UDP port, then write out the provided command:

Убейте все соответствующие процессы в Windows из командной строки

We have demonstrated the methods to kill processes in Windows.

To kill the process in Windows, you can use Task Manager, Command Prompt, or Windows Powershell. By using Task Manager, select the process and hit the “End Task” button to kill the process. You can kill the process with Command Prompt by specifying PID or Image name in the “taskkill” command. Moreover, PowerShell utilizes the “Get-Process” and “Stop-Process” commands to kill the process. In this study, we have elaborated the methods to kill processes in Windows in detail.

  • Partition Wizard
  • Partition Manager
  • CMD Kill Process: How to Kill Process in Command Prompt

On This Page :

Why You Need to Use Windows PowerShell/CMD Kill Process

As you know, the operating system will create a process for the executable file when you start running an app. This process contains the program code and its current activity. In addition, you can find the Process Identifier (PID) assigned by Windows to identify each process.

Sometimes you have to kill a process if an app is not responding or behaves unexpectedly, system resources are much occupied, or other reasons. When it comes to killing a process, most people may open Task Manager by pressing Ctrl + Shift + Esc keys and then right-click the Process and select End task.

Убейте все соответствующие процессы в Windows из командной строки

How to Kill Process CMD/PowerShell in Windows 10/11

This part will show you how to kill process Windows command line/PowerShell. You can choose one according to your preference.

# 1. CMD Kill Process

Убейте все соответствующие процессы в Windows из командной строки

Убейте все соответствующие процессы в Windows из командной строки

taskkill /F /PID pid_number

Убейте все соответствующие процессы в Windows из командной строки

taskkill /IM “process name” /F

Убейте все соответствующие процессы в Windows из командной строки

Убейте все соответствующие процессы в Windows из командной строки

Убейте все соответствующие процессы в Windows из командной строки

Убейте все соответствующие процессы в Windows из командной строки

# 2. PowerShell Kill Process

In addition, you can make Windows kill process command line via PowerShell. Here’s how to do that:

Убейте все соответствующие процессы в Windows из командной строки

Stop-Process -Name “ProcessName” -Force

Stop-Process -ID PID -Force

Команда TSKILL похожа на команду TASKKILL но более адаптирована для использования на сервере терминалов Microsoft. При большом количестве удаленных пользователей, данная команда удобнее, чем TASKKILL поскольку имеет параметры командной строки для использования по отношению к сеансам удаленного рабочего стола.

Параметры командной строки:

id процесса – уникальный идентификатор процесса.

имя процесса – имя процесса, как правило – имя исполняемого файла без расширения, например – Firefox.

/SERVER:сервер терминалов – имя или адрес сервера терминалов.

id сеанса – идентификатор сеанса, уникальный для каждого подключения к удаленному рабочему стола по протоколу RDP (Remote Desktop Protocol).

/A – Прекратить процесс, выполняемый во всех сеансах.

/V – Отображение информации о выполненных действиях.

Идентификаторы сеансов пользователей можно определить с помощью команды QUERY:

query session – отобразить сведения о пользовательских сеансах. Пример отображаемой информации:

СЕАНС             ПОЛЬЗОВАТЕЛЬ        ID         СТАТУС        ТИП

Для получения списка сеансов пользователей на удаленном сервере терминалов используется команда:

query session /server:winsrv2016 – получить информацию о сеансах пользователей с сервера winsrv2016.

Для выполнения данной команды требуются права администратора по отношению к удаленной системе и некоторые настройки безопасности, приведенные на странице с описанием команды QUERY.

Примеры использования TSKILL:

tskill.exe 2425 – уничтожить процесс с идентификатором 2425. Идентификаторы процессов можно получить с помощью команды TASKLIST

tskill.exe Firefox – завершить процесс с именем Firefox. Процесс с указанным именем будет завершен только для сеанса текущего пользователя. Все прочие процессы с таким же именем, существующие в сеансах других пользователей сервера терминалов не будут затронуты. При использовании команды TSKKILL для завершения процесса по имени, при наличии соответствующих прав, локальный администратор завершит процесс не только для себя, но и для всех пользователей удаленного рабочего стола.

tskill firefox /server:win10 /A – завершить процесс firefox для всех сеансов пользователей на сервере win10 Процесс будет завершен не только в среде сеансов пользователей удаленного рабочего стола, но и в среде локального пользователя.

Оставьте комментарий