diff --git a/ethend.bat b/ethend.bat index 81b66e7..a64af94 100644 --- a/ethend.bat +++ b/ethend.bat @@ -126,17 +126,19 @@ if %ERRORLEVEL%==0 ( exit /b 0 ) -:: Check port conflict and ask user -for /f "tokens=5" %%a in ('netstat -ano ^| findstr /R ":%ETHEND_PORT% " ^| findstr "LISTENING"') do ( +:: Check port conflict +set FOUND_PID= +for /f "tokens=5" %%a in ('netstat -ano ^| findstr /R ":%ETHEND_PORT% " ^| findstr "LISTENING"') do set FOUND_PID=%%a +if not "%FOUND_PID%"=="" ( echo. - echo [WARN] Port %ETHEND_PORT% is in use by PID %%a. + echo [WARN] Port %ETHEND_PORT% is in use by PID %FOUND_PID%. set /p CHOICE="Kill old process and restart? [Y/n]: " if /i "!CHOICE!"=="n" ( echo [INFO] Aborted by user. exit /b 0 ) - echo [INFO] Killing PID %%a... - taskkill /PID %%a /F >nul 2>&1 + echo [INFO] Killing PID %FOUND_PID%... + taskkill /PID %FOUND_PID% /F >nul 2>&1 timeout /t 2 /nobreak >nul )