@echo off setlocal EnableExtensions cd /d "%~dp0backend" set "PLAYWRIGHT_BROWSERS_PATH=%LOCALAPPDATA%\ms-playwright" echo [System] Checking port 8800... for /f "tokens=5" %%P in ('%SystemRoot%\System32\netstat.exe -aon ^| %SystemRoot%\System32\findstr.exe ":8800" ^| %SystemRoot%\System32\findstr.exe "LISTENING"') do ( if not "%%P"=="0" ( echo [System] Stopping process on port 8800, PID %%P %SystemRoot%\System32\taskkill.exe /F /PID %%P >nul 2>&1 ) ) REM Fallback if netstat loop failed powershell -NoProfile -ExecutionPolicy Bypass -Command ^ "$p = Get-NetTCPConnection -LocalPort 8800 -State Listen -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique; foreach ($i in $p) { if ($i) { Write-Host ('[System] Stopping PID ' + $i); Stop-Process -Id $i -Force -ErrorAction SilentlyContinue } }" ^ 2>nul ping -n 2 127.0.0.1 >nul echo [System] Starting FastAPI backend... echo [System] URL: http://localhost:8800 echo [System] Web UI: http://localhost:8800 - use start_web.bat for full UI echo [System] Playwright browsers: %PLAYWRIGHT_BROWSERS_PATH% echo [System] Login flow: wait for browser scan, auto-save cookie echo. if not exist ".venv\Scripts\uvicorn.exe" ( echo [Error] uvicorn not found. Run install.bat first. pause exit /b 1 ) call .venv\Scripts\uvicorn.exe main:app --host 0.0.0.0 --port 8800 if errorlevel 1 ( echo. echo [Error] Backend failed to start. echo Port 8800 may still be in use. Close other backend windows and retry. echo Or run: taskkill /F /PID ^ after: netstat -ano ^| findstr :8800 pause exit /b 1 )