Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VC++ SetEnv.cmd in a batch file

I would like to do a batch file that calls setenv.cmd and continues with some other commands like :

%COMSPEC% /E:ON /V:ON /K "%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd"

setenv /Release /x86
set DISTUTILS_USE_SDK=1
set MSSdk=1
python setup.py build

Unfortunately, the batch stops after the 1st line because it calls something close to a new cmd.exe. I also tried with

call "%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd /Release /x86

but, unsuccessfully : the initial batch is still stopped after executing this setenv.cmd.

What is proper way to call setenv.cmd and continuing a batch process ?

like image 590
Basj Avatar asked Feb 28 '26 12:02

Basj


1 Answers

Use call to run a batch script in your current context - that is to have any environment variables set their values in the parent context. ie:

@call "%VSCOMNTOOLS%\SetEnv.cmd"

Edit

Here is how I actually setup the compiler environment in one of our build scripts. We have a chunk of code that sets PF to the 32 bit program files path for the current system. Then call vcvars32.bat to configure the compiler environment. If SetEnv.cmd is not working for you, using vcvars is likely to be ok.

@rem Note: can use @call "%VS120COMNTOOLS%\..\..\VC\bin\vcvars32.bat"
if "%VCINSTALLDIR%"=="" call "%PF%\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
like image 124
patthoyts Avatar answered Mar 03 '26 07:03

patthoyts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!