window批处理杀死指定端口进程

@echo off
setlocal enabledelayedexpansion
set /p port=请输入端口号:
for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do (
    if "%%e%" == "" (
        set pid=%%d
    ) else (
        set pid=%%e
    )
    echo !pid!
    taskkill /f /pid !pid!
)
pause
posted @ 2017-12-27 21:10  Earic  阅读(1286)  评论(0编辑  收藏  举报