fix(run.bat): evita Microsoft Store Python stub care termina cmd.exe

Store stub-ul pentru python.exe termina procesul batch cand e apelat
direct. Fix: foloseste 'py' launcher (safe) sau detecteaza python.exe
real via 'where | findstr /v WindowsApps', fara a executa python
in contextul check-ului. Toate apelurile python -> !PYTHON_CMD!.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 02:06:42 +02:00
parent e83bd74813
commit 7b18e8fc41

30
run.bat
View File

@@ -18,17 +18,31 @@ set "NEED_WHISPER="
set "NEED_MODEL="
:: --- Python ---
python --version >nul 2>&1
if errorlevel 1 (
:: Avoid executing python.exe directly — the Microsoft Store stub terminates cmd.exe.
:: Use 'py' launcher first (safe), then find python.exe excluding WindowsApps stub.
set "PYTHON_CMD="
where py >nul 2>&1
if not errorlevel 1 (
set "PYTHON_CMD=py"
for /f "tokens=2" %%v in ('py --version 2^>^&1') do echo [OK] Python %%v (py launcher^)
)
if not defined PYTHON_CMD (
for /f "delims=" %%p in ('where python 2^>nul ^| findstr /v /i "WindowsApps"') do (
if not defined PYTHON_CMD (
set "PYTHON_CMD=%%p"
for /f "tokens=2" %%v in ('"%%p" --version 2^>^&1') do echo [OK] Python %%v
)
)
)
if not defined PYTHON_CMD (
echo [X] Python NOT FOUND
echo The Microsoft Store stub does not count as a real Python install.
echo Install from: https://www.python.org/downloads/
echo Make sure to check "Add Python to PATH" during install.
echo.
echo Cannot continue without Python. Install it and re-run.
pause
exit /b 1
) else (
for /f "tokens=2" %%v in ('python --version 2^>^&1') do echo [OK] Python %%v
)
:: --- .env credentials ---
@@ -156,7 +170,7 @@ if defined NEED_FFMPEG (
echo ============================================================
echo Auto-downloading ffmpeg...
echo ============================================================
python setup_whisper.py ffmpeg
"!PYTHON_CMD!" setup_whisper.py ffmpeg
if errorlevel 1 (
echo.
echo ERROR: Could not install ffmpeg.
@@ -178,7 +192,7 @@ if defined NEED_WHISPER (
echo ============================================================
echo Auto-downloading whisper.cpp (CPU build^)...
echo ============================================================
python setup_whisper.py whisper
"!PYTHON_CMD!" setup_whisper.py whisper
if errorlevel 1 (
echo.
echo ERROR: Failed to auto-download whisper.cpp.
@@ -200,7 +214,7 @@ if defined NEED_MODEL (
echo Auto-downloading Whisper model (ggml-medium-q5_0, ~500 MB^)...
echo This will take a few minutes depending on your connection.
echo ============================================================
python setup_whisper.py model
"!PYTHON_CMD!" setup_whisper.py model
if errorlevel 1 (
echo.
echo ERROR: Failed to download model.
@@ -225,7 +239,7 @@ echo.
:: ============================================================
if not exist ".venv\Scripts\python.exe" (
echo [1/4] Creating Python virtual environment...
python -m venv .venv
"!PYTHON_CMD!" -m venv .venv
if errorlevel 1 (
echo ERROR: Failed to create venv.
pause