PageSourceSearch

https://blog.marcnuri.com/component---src-components-templates-pos…command-line-en-mdx-64f437f3809999d6570c.js

js marcnuri.com collected 2026-09-24 19:53:47 UTC 5,174 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_marcnuri_blog_marcnuri_com=self.webpackChunk_marcnuri_blog_marcnuri_com||[]).push([[1963],{54627:function(e,n,t){t.r(n),t.d(n,{default:function(){return m}});var l=t(28453),o=t(96540);function a(e){const n=Object.assign({h2:"h2",p:"p",a:"a",code:"code",pre:"pre",img:"img"},(0,l.RP)(),e.components);return o.createElement(o.Fragment,null,o.createElement(n.h2,{id:"introduction"},"Introduction"),"\n",o.createElement(n.p,null,"When writing a script or simply working from the command line, sometimes it is necessary to kill a process.\nIn ",o.createElement(n.a,{href:"tag#windows"},"Windows"),", this can be done in several ways depending on the terminal tool you are using (cmd, powershell, and so on)."),"\n",o.createElement(n.p,null,"In this post, I will show you how to kill a process from the command line in Windows."),"\n",o.createElement(n.h2,{id:"how-to-kill-a-process-from-cmd"},"How to kill a process from cmd"),"\n",o.createElement(n.p,null,"To kill a process from the command line, we will use the ",o.
1createElement(n.code,null,"taskkill")," command.\nThis command is available in Windows XP and later versions of Windows."),"\n",o.createElement(n.p,null,"If you know the process ID (PID), you can use the following command:"),"\n",o.createElement(n.pre,null,o.createElement(n.code,{className:"language-powershell",title:"cmd.exe"},"taskkill /F /PID <pid>\n")),"\n",o.createElement(n.p,null,"For example, consider that we need to kill a process that is blocking a TCP port.\nWe've retrieved its PID ",o.createElement(n.a,{href:"post#how-to-check-open-ports-in-windows"},"using the ",o.createElement(n.code,null,"netstat")," command")," as I explained in the previous ",o.createElement(n.a,{href:"post#how-to-check-open-ports-in-windows"},"post"),".\nThe PID is ",o.createElement(n.code,null,"4027"),", so we can kill it using the following command:"),"\n",o.createElement(n.img,{src:"./cmd-taskkill-pid.jpg",alt:"A screenshot showing the output of the taskkill /F /PID 4027 command"}),"\n",o.createElement(n.p,null,"Taskkill also supports killing a process by its name.\nTo do so, you can use the following command:"),"\n",o.createElement(n.pre,null,o.createElement(n.code,{className:"language-powershell",title:"cmd.exe"},"taskkill /F /IM <process name>\n")),"\n",o.createElement(n.p,null,"For example, to kill all the ",o.createElement(n.code,null,"notepad.exe")," processes, you can use the following command:"),"\n",o.createElement(n.img,{src:"./cmd-taskkill-name.jpg",alt:"A screenshot showing the output of the taskkill /F /IM notepad.exe command"}),"\n",o.createElement(n.h2,{id:"how-to-kill-a-process-from-powershell"},"How to kill a process from PowerShell"),"\n",o.createElement(n.p,null,"To kill a process from PowerShell, we will use the ",o.
1createElement(n.a,{href:"https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/stop-process"},o.createElement(n.code,null,"Stop-Process")," cmdlet"),"."),"\n",o.createElement(n.p,null,"Just like with ",o.createElement(n.code,null,"taskkill"),", if you know the process ID (PID), you can use the following command:"),"\n",o.createElement(n.pre,null,o.createElement(n.code,{className:"language-powershell",title:"Windows PowerShell"},"Stop-Process -Force -Id <pid>\n")),"\n",o.createElement(n.p,null,"For example, to kill the process with PID ",o.createElement(n.code,null,"3572"),", you can use the following command:"),"\n",o.createElement(n.img,{src:"./powershell-stop-process-id.jpg",alt:"A screenshot showing the output of the Stop-Process -Force -Id <pid> command"}),"\n",o.createElement(n.p,null,"In addition to the long format, ",o.createElement(n.code,null,"Stop-Process")," has two other aliases that you can use instead: ",o.createElement(n.code,null,"kill")," and ",o.createElement(n.code,null,"spps"),"."),"\n",o.createElement(n.p,null,"We can also kill a process by its name.\nTo do so, you can use the following command:"),"\n",o.createElement(n.pre,null,o.createElement(n.code,{className:"language-powershell",title:"Windows PowerShell"},"Stop-Process -Name <process name>\n")),"\n",o.createElement(n.p,null,"For example, to kill the ",o.createElement(n.code,null,"Notepad")," process, you can use the following command:"),"\n",o.createElement(n.img,{src:"./powershell-kill-name.jpg",alt:"A screenshot showing the output of the kill -Name notepad command"}),"\n",o.createElement(n.h2,{id:"conclusion"},"Conclusion"),"\n",o.createElement(n.p,null,"In this post, I've shown you the possible ways to kill a process from the command line in Windows.\nUsing the ",o.createElement(n.code,null,"taskkill")," command from cmd or the ",o.createElement(n.code,null,"Stop-Process")," cmdlet from powershell.\nI hope you find it useful."))}var s=function(e){void 0===e&&(e={});const{wrapper:n}=Object.assign({},(0,l.RP)(),e.components);return n?o.createElement(n,e,o.createElement(a,e)):a(e)},c=t(37698);const r=e=>o.createElement(c.TP,{pageContext:e.pageContext},o.createElement(c.n$,Object.assign({comments:e.pageContext.comments,frontmatter:e.pageContext.frontmatter},e)));function m(e){return o.createElement(r,e,o.createElement(s,e))}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.