dos命令
@echo off
rem Step 1. Find the java process according to the port number and end the process
rem Set the listening port number
set serverPort=8084
echo port : %serverPort%
for /f “usebackq tokens=1-5” %%a in (netstat -ano ^| findstr %serverPort%
) do (
if [%%d] EQU [LISTENING] (
set pid=%%e
)
)
for /f “usebackq tokens=1-5” %%a in (tasklist ^| findstr %pid%
) do (
set image_name=%%a
)
echo now will kill process : pid %pid%, image_name %image_name%
rem Kill process according to process ID
taskkill /f /pid %pid%
timeout /nobreak /t 2
exit;