Files
mediaplayer/start_windows.bat
2026-08-11 14:14:56 +08:00

39 lines
1.1 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
chcp 65001 >nul
setlocal
cd /d "%~dp0"
rem 查找 conda优先使用 PATH 中的 conda否则在常见安装目录中查找
set "CONDA_BASE="
where conda >nul 2>nul
if not errorlevel 1 (
for /f "delims=" %%i in ('conda info --base') do set "CONDA_BASE=%%i"
)
if not defined CONDA_BASE (
for %%C in ("%USERPROFILE%\anaconda3" "%USERPROFILE%\miniconda3" "%ProgramData%\Anaconda3" "%ProgramData%\Miniconda3" "C:\anaconda3" "C:\miniconda3") do (
if exist "%%~C\Scripts\activate.bat" set "CONDA_BASE=%%~C"
)
)
if not defined CONDA_BASE (
echo [错误] 未找到 conda请先安装 Anaconda 或 Miniconda。
pause
exit /b 1
)
call "%CONDA_BASE%\Scripts\activate.bat" mediaplayer
if errorlevel 1 (
echo [错误] 激活 mediaplayer 环境失败,请确认已创建该环境。
pause
exit /b 1
)
python -c "import sys; sys.exit(0 if 'mediaplayer' in sys.prefix else 1)" >nul 2>nul
if errorlevel 1 (
echo [错误] mediaplayer 环境未正确激活。
pause
exit /b 1
)
python media_player.py %*
if errorlevel 1 pause