diff --git a/setup-windows.bat b/setup-windows.bat index d87b126..7d27df5 100644 --- a/setup-windows.bat +++ b/setup-windows.bat @@ -139,6 +139,19 @@ REM its major version separates a real interpreter from the stub. The py REM launcher is preferred when present - it is not shadowed by the stub. :py_probe set "PYCMD=" +for /f "tokens=*" %%v in ('py -3 -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=py -3" +if not defined PYCMD for /f "tokens=*" %%v in ('python -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=python" +if defined PYCMD goto :py_found + +REM Not on PATH. Same story as Git and Node: a Python installed just now - or +REM installed without "Add to PATH" ticked - is invisible to this session, which +REM inherited its PATH at start. Prepend the standard install homes and retry. +REM The version is globbed rather than hardcoded so a 3.13 install still works. +for /d %%D in ("%LOCALAPPDATA%\Programs\Python\Python3*") do if exist "%%~D\python.exe" set "PATH=%%~D;%%~D\Scripts;%PATH%" +for /d %%D in ("%ProgramFiles%\Python3*") do if exist "%%~D\python.exe" set "PATH=%%~D;%%~D\Scripts;%PATH%" +if exist "%LOCALAPPDATA%\Programs\Python\Launcher\py.exe" set "PATH=%LOCALAPPDATA%\Programs\Python\Launcher;%PATH%" +if exist "%SystemRoot%\py.exe" set "PATH=%SystemRoot%;%PATH%" + for /f "tokens=*" %%v in ('py -3 -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=py -3" if not defined PYCMD for /f "tokens=*" %%v in ('python -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=python" if defined PYCMD goto :py_found @@ -156,8 +169,12 @@ winget install --id Python.Python.3.12 -e --source winget --accept-source-agreem goto :py_probe :py_skip -echo [--] python not found - the dashboard will still work. -echo Needed only for the clicker ^(clicker\runner.py^). +echo [--] python not found on PATH, and not in any of: +echo %LOCALAPPDATA%\Programs\Python\Python3* +echo %ProgramFiles%\Python3* +echo The dashboard will still work - python is only needed for the +echo clicker ^(clicker\runner.py^). If you just installed it, close this +echo window and re-run to pick up the new PATH. goto :py_end :py_found