@echo off setlocal EnableExtensions cd /d "%~dp0" set "PORT=31000" set "FOUND=0" rem Find the PID listening on FlowApi's configured port. for /f "tokens=5" %%P in ('netstat -ano -p tcp ^| findstr ":%PORT%" ^| findstr "LISTENING"') do ( set "FOUND=1" echo Stopping FlowApi process %%P... taskkill /PID %%P /T /F >nul 2>&1 ) if "%FOUND%"=="0" ( echo No process is listening on port %PORT%. FlowApi is not running. ) else ( echo FlowApi stop command completed. ) endlocal