@echo off setlocal title MAPS to DXF cd /d "%~dp0" where node >nul 2>&1 if errorlevel 1 goto INSTALL_NODE goto DEPS :INSTALL_NODE echo Node.js not found. Installing via Windows Package Manager... winget install OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements if errorlevel 1 goto NODE_FAIL echo Node.js installed. Close this window, then double-click Start.bat again. pause exit /b 0 :NODE_FAIL echo Could not install Node.js automatically. Opening download page... start https://nodejs.org/ echo After installing Node.js, close this window and double-click Start.bat again. pause exit /b 1 :DEPS if not exist "node_modules\express" goto NPM_INSTALL if not exist "node_modules\multer" goto NPM_INSTALL goto PORTS :NPM_INSTALL echo Installing dependencies... call npm install if errorlevel 1 goto NPM_FAIL goto PORTS :NPM_FAIL echo npm install failed. pause exit /b 1 :PORTS echo Freeing ports 3456 and 3457 if a previous run is still open... powershell -NoProfile -Command "foreach ($p in 3456,3457) { Get-NetTCPConnection -LocalPort $p -State Listen -ErrorAction SilentlyContinue | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue } }" >nul 2>&1 set "PY=" where python >nul 2>&1 if not errorlevel 1 set "PY=python" if defined PY goto ML_DEPS where py >nul 2>&1 if not errorlevel 1 set "PY=py" if not defined PY goto START_APP :ML_DEPS if not exist "ml_server\requirements.txt" goto START_APP echo Checking Python ML dependencies... "%PY%" -m pip install -r "ml_server\requirements.txt" -q :START_APP echo Starting MAPS to DXF... echo Browser will open. Keep this window open. echo Close this window to stop the app. echo. node server.js echo. pause