用 taskkill 按 PID 结束进程及其子进程

用查到的数字 PID 结束某个进程以及它启动的所有子进程。

Windows进程终端taskkill中风险
运行 taskkill /PID <PID> /T /F,把 <PID> 换成你查到的那个数字进程号,例如 taskkill /PID 12345 /T /F。

01命令

命令
$ taskkill /PID <PID> /T /F

02作用说明

taskkill 通过数字 PID 定位进程。/T 会一并结束该进程启动的子进程——开发服务器和 Electron 应用通常会派生出好几个,不结束它们端口会一直被占着。/F 表示强制结束,而不是请求进程自行退出。PID 可以先用 Get-NetTCPConnection -LocalPort 8080 | Select-Object OwningProcess 获取,也可以在任务管理器「详细信息」标签页里查看。

03风险

风险中风险
使用条件An elevated Command Prompt if the process belongs to another user or to a system service.
!注意: 结束进程会丢失它未保存的内容。执行前请确认这个 PID 确实是你想停掉的那个程序——结束系统服务可能导致系统需要重启。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • taskkill — Microsoft Learn
    Microsoft · vendor-doc · 2026-09-21
    依据: /PID <processid> specifies the process to terminate; /T ends the specified process and any child processes started by it; /F forces termination.
  • taskkill — Windows CMD reference
    SS64 · technical · 2026-09-21
    依据: TASKKILL /PID pid /T /F terminates the given process and its child processes forcefully.

最后验证: 2026-09-22 · 分类: 系统与设置

06相关方案