diff --git a/服务管理.bat b/服务管理.bat index 82b5a1f..6a67b8d 100644 --- a/服务管理.bat +++ b/服务管理.bat @@ -27,14 +27,18 @@ if not exist "%NSSM_EXE%" ( ) REM 检查虚拟环境 +set "PYTHON_PATH=" if exist ".venv\Scripts\python.exe" ( - set PYTHON_PATH=%cd%\.venv\Scripts\python.exe + set "PYTHON_PATH=%cd%\.venv\Scripts\python.exe" ) else ( - for /f "delims=" %%i in ('where python') do ( - set PYTHON_PATH=%%i - goto :found_python + for /f "delims=" %%i in ('where python 2^>nul') do ( + if not defined PYTHON_PATH set "PYTHON_PATH=%%i" + ) + if not defined PYTHON_PATH ( + echo [错误] 未找到 Python,请先安装 Python 或创建虚拟环境 + pause + exit /b 1 ) - :found_python ) echo ========================================