I'm trying to make a batch script (called run_windows) that check if the python virtual environment exists and if not, create it then activate it, install the requirements and finally run some python code.
set "VIRTUAL_ENV=mat_visualizer_env"
:read_mat
%VIRTUAL_ENV%\Scripts\activate
pip install -r app_files/requirements.txt
python -c "import sys; sys.path.insert(1,'app_files'); from main import visualize_mat_eeg; visualize_mat_eeg('%1')"
pause
EXIT /B 0
IF EXIST "%VIRTUAL_ENV%\Scripts\activate.bat" (
CALL :read_mat
) ELSE (
pip install virtualenv
python -m venv mat_visualizer_env
CALL :read_mat
)
However, when I run my script, the code exits at line 4: %VIRTUAL_ENV%\Scripts\activate with no errors:

%VIRTUAL_ENV%\Scripts\activate.bat? I believe theactivatescript is a bash script.Call "%VIRTUAL_ENV%\Scripts\activate.bat". If you weren't using lazy code, and you understood theactivatewas really a batch file, should know that to run a batch file from another cmd instance, and return to the original instance whilst maintaining its environment, you must useCALL..batdidn't change anything.Callis the essential part of my comment! (.batand the doublequotes, are best practice recommendations). Did you not read it? or see the word must?