Uncategorized

Killing a command line process in Windows – le crab info

You have had enough of kill a process via Task Manager in Windows?

With the method I am going to suggest to you, you will no longer be forced to stop a program via this good old task manager: I will show you how to kill a process via the command line ! Don’t be afraid, everything will be fine 😉 Kill a processor via the command line is faster, more informative, and more swag, you know.

When I want force stop an application in Windows, I find that the graphical interface is not the most suitable solution. We must scroll on several lines until we find the name of our application and then click on the “End of task” button. Well, I admit it: it’s not the end of the world… when it works! Because it often happens to me that despite clicking on this “End task” button, nothing happens 😐 And then, when you have to delete several processes, the task manager quickly becomes tedious …

Two Spotify processes.  Despite repeated clicks on the button
Two Spotify processes. Despite repeated clicks on the “End of task” button, nothing happens …

Kill a process via the command linee, this is something that is often done under a GNU / Linux distribution where the power of the command line is such that it is called upon very often. I got used to this way of doing things, which I find more practical, faster and above all more informative. A graphical interface is certainly a way to make things easier for the end user to use, but it does not allow you to really understand how everything works in reality. In short, I said to myself that we could surely do the same under Windows. And that’s the case ! Let’s see how stop a command line process on Windows.

Open the Windows command prompt. To keep it simple, press the keys Windows + R on your keyboard and type cmd in the Run command.

kill-cmd-windows-cmd-command-line-process

Enter the command tasklist and hit Enter to display a list of all active processes.

kill-command-line-process-cmd-windows-tasklist

All the your Windows session process are displayed with the following information: the image name of the process, its PID, the name of the session, the session number and its use in KB. There are quite a few, several lines are displayed, difficult to understand. spot 😐

kill-process-command-line-cmd-windows-process-list

Fortunately, we are going to use a command that will allow us to filter the result of the command. tasklist. For example, if you are looking for the processes related to the Spotify app, enter the following command:

tasklist | findstr /i "spotify"

findstr allows you to filter the result of the previous command (tasklist). The argument /i specifies that the search should be case-insensitive.

Now, as we can see in the capture below, tasklist now only displays the processes related to the application you are looking for, in this case Spotify. We have three Spotify.exe processes to kill!

kill-process-command-line-cmd-windows-filter-process-findstr

To kill a process via the command line, we will use the command taskkill :

taskkill /f /im Spotify.exe (remplacez Spotify.exe par le nom de votre processus)

The argument /f forces processes to end, the argument /im specifies the image name of the process to terminate (in the example above, the process image name is “Spotify.exe”).

You can also kill a process by specifying its PID using the argument /PID :

taskkill /PID 12460 (remplacez 12460 par le PID de votre processus)

But the advantage of killing with the argument /im (by specifying the image name of the process therefore) is that we can kill several processes with the same name at the same time. Using the command taskkill /f /im Spotify.exe, I kill all three Spotify.exe processes at once 🙂

You should get the message “Operation successful: process ‘xxx.exe’ from PID nnn has been terminated.”

kill-process-command-line-cmd-windows-kill-process-taskkill

Let’s check that our application has been stopped with the command:

tasklist | findstr /i "spotify"

kill-process-command-line-cmd-windows-verifier-process-kill-kill

And there you have it, we have correctly kill an application via the Windows command line ! Happy ? 😀

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker