diff --git a/setup-windows.bat b/setup-windows.bat index 9a8c01a..c2c610f 100644 --- a/setup-windows.bat +++ b/setup-windows.bat @@ -21,21 +21,47 @@ echo ============================================ echo. REM ---------------------------------------------------------------- git check +REM Git for Windows only adds itself to PATH if "Git from the command line" was +REM chosen at install time, and an already-open cmd keeps its old PATH anyway. +REM So probe the usual install homes before giving up. where git >nul 2>&1 -if errorlevel 1 ( - echo [X] Git is not installed, or not on PATH. - echo Install it from https://git-scm.com/download/win then re-run. - goto :fail +if not errorlevel 1 goto :git_ok +if exist "%ProgramFiles%\Git\cmd\git.exe" set "PATH=%ProgramFiles%\Git\cmd;%PATH%" +if exist "%ProgramFiles(x86)%\Git\cmd\git.exe" set "PATH=%ProgramFiles(x86)%\Git\cmd;%PATH%" +if exist "%LOCALAPPDATA%\Programs\Git\cmd\git.exe" set "PATH=%LOCALAPPDATA%\Programs\Git\cmd;%PATH%" +where git >nul 2>&1 +if not errorlevel 1 ( + echo [ok] git ^(found off PATH, added for this run^) + goto :git_done ) +echo [X] Git not found on PATH, and not in any of: +echo %ProgramFiles%\Git\cmd +echo %LOCALAPPDATA%\Programs\Git\cmd +echo. +echo If Git is NOT installed: https://git-scm.com/download/win +echo If you JUST installed it: close this window, open a new Command +echo Prompt and run the script again - an open window keeps its old PATH. +echo If it is installed elsewhere: check with where git +goto :fail +:git_ok echo [ok] git +:git_done REM --------------------------------------------------------------- node check where node >nul 2>&1 -if errorlevel 1 ( - echo [X] Node.js is not installed, or not on PATH. - echo Install Node 22 LTS from https://nodejs.org/ then re-run. - goto :fail -) +if not errorlevel 1 goto :node_found +if exist "%ProgramFiles%\nodejs\node.exe" set "PATH=%ProgramFiles%\nodejs;%PATH%" +if exist "%LOCALAPPDATA%\Programs\nodejs\node.exe" set "PATH=%LOCALAPPDATA%\Programs\nodejs;%PATH%" +where node >nul 2>&1 +if not errorlevel 1 goto :node_found +echo [X] Node.js not found on PATH, and not in any of: +echo %ProgramFiles%\nodejs +echo %LOCALAPPDATA%\Programs\nodejs +echo. +echo Install Node 22 LTS from https://nodejs.org/ then re-run. +echo If you JUST installed it, open a NEW Command Prompt first. +goto :fail +:node_found for /f "tokens=* usebackq" %%v in (`node -p "process.versions.node"`) do set "NODEVER=%%v" for /f "tokens=1 delims=." %%m in ("%NODEVER%") do set "NODEMAJOR=%%m" echo [ok] node v%NODEVER%