@echo off
set port=9000//程序运行的端口号for/f "tokens=1-5"%%i in ('netstat -ano^|findstr ":%port%"')do(
echo kill the process %%m who use the port
taskkill /pid %%m -t -f
goto q
):q
重启
@echo off
set port=9000//需要关闭的端口号for/f "tokens=1-5"%%i in ('netstat -ano^|findstr ":%port%"')do(
echo kill the process %%m who use the port
taskkill /pid %%m -t -f
goto start
):start
start cmd /c "java -jar new-xxx.jar"
spause