@echo off
setlocal enabledelayedexpansion
set /p port=pls input port need to kill=
for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do (
if "%%e%" == "0" (
set pid=%%d
echo no task has used port 【%port%】
) else (
set pid=%%e
echo find %port% in pid =!pid!
taskkill /f /pid !pid!
pause
)
)