Is there a way to push and pop all environment variables in a batch script?
Use setlocal, see setlocal /?
or ss64.com/nt/setlocal
Setlocal
call "%VS140COMNTOOLS%\vsvars32.bat"
(do some stuff...)
Endlocal
Setlocal
call "%VS90COMNTOOLS%\vsvars32.bat"
(do some other stuff...)
Endlocal
To save the current variable state you could do
set >MyVarStatus.txt
and restore later on with
@Echo off
For /f "tokens=1* delims==" %%A in (
'findstr /V "^Path" MYVarStatus.txt '
) Do Set %%A=%%B
this would exclude the Path variables.