Advertisement

How to end a process with PowerShell

Windows offers you many different ways to terminate a process. It can be done with Task Manager, with the console tool taskkill and with a huge number of third party apps. Let's see one more method. Today, we will see how to end a process using PowerShell.

Advertisеment


PowerShell comes with a useful cmdlet "Stop-Process". It allows you to terminate a single process or multiple processes. There are several ways to use it.
Let's see how.

How to end a process with PowerShell

Table of contents

  1. Terminate a process by its ID
  2. Terminate a process by its name

Terminate a process by its ID

If you know the process ID you want to kill, you can use it in the Stop-Process cmdlet. If you do not know it, you can use the Get-Process cmdlet to find it. Run it without parameters to get the list of processes with their IDs. See the following screenshot:

get-processIn this example, I am going to kill regedit.exe. Its ID is 3420. It should be done as follows:

Stop-Process 3420

Note: to terminate an elevated process, you need to open PowerShell as Administrator. Please refer to the following article:

All ways to open PowerShell in Windows 10

Otherwise you'll get the following error message: "Access is denied".

access-deniedIt works from the elevated instance:

killed-process

Terminate a process by its name

Another way to use Stop-Process is killing process by its name. The syntax is as follows:

Stop-Process -processname regedit

killed-process-by-nameYou can even end multiple apps at once by typing their process names delimited by a comma:

Stop-Process -processname regedit, regownershipex

The above command will terminate Registry Editor and the RegOwnershipEx app.

killed-processes

Tip: for the Stop-Process cmdlet, you can use the following short aliases:

spps
kill

For the Get-Process cmdlet, use the following aliases:

gps
ps

Support us

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

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

3 thoughts on “How to end a process with PowerShell”

  1. Hi, thank you very much for the stop-process -processname “NAMEOFAPPLICATIONHERE” without quotes help.
    I was wondering, if I use stop-process, does it close the application safely, just like Windows does, or does it force-close it which results in data loss with apps, for example, that have my database inside.
    Closing a database on my computer that uses about 10GB of system memory takes a few seconds to save to disk.
    Thanks.

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.