Question

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 ?

Was it helpful?

Solution

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top