@echo off setlocal set PORT=3000 echo Looking for process on port %PORT%... :: 查找占用端口 3000 的进程 PID set PID= for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":%PORT% " ^| findstr "LISTENING"') do ( set PID=%%a ) if defined PID ( echo Found process with PID: %PID% echo Killing process... taskkill /F /PID %PID% echo Server stopped successfully. ) else ( echo No server found running on port %PORT%. ) pause