如何只用一行命令杀掉某个端口号的Windows进程?

如何只用一行命令杀掉某个端口号的Windows进程?

For use in command line:

1
for /f "tokens=5" %a in ('netstat -aon ^| find ":8080" ^| find "LISTENING"') do taskkill /f /pid %a

For use in bat-file:

1
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8080" ^| find "LISTENING"') do taskkill /f /pid %%a

If you want to do it in a .bat, replace %a for %%

转自:Stack Overflow

本文标题:如何只用一行命令杀掉某个端口号的Windows进程?

文章作者:陈宸

发布时间:2020年02月25日 - 11:05

最后更新:2020年02月25日 - 11:10

原始链接:https://realcjames.github.io/2020/02/25/%E5%A6%82%E4%BD%95%E5%8F%AA%E7%94%A8%E4%B8%80%E8%A1%8C%E5%91%BD%E4%BB%A4%E6%9D%80%E6%8E%89%E6%9F%90%E4%B8%AA%E7%AB%AF%E5%8F%A3%E5%8F%B7%E7%9A%84Windows%E8%BF%9B%E7%A8%8B/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------本文结束感谢您的阅读-------------