@echo off setlocal EnableDelayedExpansion :: check if the script is at the correct place echo. if not exist ".\blender.exe" ( echo ERROR: echo Script is not located at the correct position... echo Put it in the same folder as the "blender.exe" file. echo. pause exit ) :: check blender's python version if exist ".\2.79\python" ( for /f "delims=" %%i in ('.\2.79\python\bin\python.exe -c "import sys; print(sys.version[:3])"') do set blender_python_version=%%i ) if exist ".\2.79\python_original" ( for /f "delims=" %%i in ('.\2.79\python_original\bin\python.exe -c "import sys; print(sys.version[:3])"') do set blender_python_version=%%i ) echo. echo Blender Python version: %blender_python_version% :: check if the manually installed version exists :: Python 3.5 echo. if "%blender_python_version%" == "3.5" ( py -3.5 --version if !errorlevel! geq 1 ( echo. echo ERROR: echo Python 3.5 is not installed... echo Be sure to add it to PATH. echo. pause exit ) goto all_is_setup ) :: Python 3.7 if "%blender_python_version%" == "3.7" ( py -3.7 --version if !errorlevel! geq 1 ( echo. echo ERROR: echo Python 3.7 is not installed... echo Be sure to add it to PATH. echo. pause exit ) goto all_is_setup ) echo. echo ERROR: echo Blender has different Python version as the one expected. echo. exit :: surely nothing else can go wrong :all_is_setup echo Correct Python version found. :: will rename the original python folder to python_original echo Renaming some files... ren .\2.79\python python_original :: will also rename the python35.dll/python37.dll if "%blender_python_version%" == "3.5" ( ren python35.dll python35_original.dll ) if "%blender_python_version%" == "3.7" ( ren python37.dll python37_original.dll ) :: set the BLENDER_SYSTEM_PYTHON variable and get the python interpreter path for /f "delims=" %%i in ('py -%blender_python_version% -c "import sys; print(sys.exec_prefix)"') do set python_base_path=%%i for /f "delims=" %%i in ('py -%blender_python_version% -c "import sys; print(sys.executable)"') do set python_interpreter_path=%%i set BLENDER_SYSTEM_PYTHON=%python_base_path% echo %BLENDER_SYSTEM_PYTHON% :: run Blender sending as first argument the python interpreter path blender.exe -- %python_interpreter_path% :: will unrename the files renamed :: so that blender can be used without Blenxy as well echo Unrenaming renamed files... ren .\2.79\python_original python if "%blender_python_version%" == "3.5" ( ren python35_original.dll python35.dll ) if "%blender_python_version%" == "3.7" ( ren python37_original.dll python37.dll ) pause