The code given below is an excerpt from vcvarsall.bat
file used to
set the environment variables for Visual C++ Command Line.
Due to the errors(mentioned in the code as REM statements), the environment variables are not set.
:x86
if exist "%~dp0bin" echo "%~dp0bin exists"
REM The above line gives "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin exists" as output.
if not exist "%~dp0bin\vcvars32.bat" goto missing
call "%~dp0bin\vcvars32.bat"
REM The above line gives 'C:\Program' is not recognized as an internal or external command as output.
goto :SetVisualStudioVersion
Since the environment variables are not set I ran into runtime errors while building an nmake project.
I have gone through this SO question and this post but the workarounds didn't help.
Could anyone suggest a workaround for calling the call
with spaces and parentheses in the path?
Edit:
I have placed a test echo
statement in the beginning of the vcvars32.bat file which is being called. Had the file been run this statement should have been executed with the statement printed on the screen. Moreover I am sure that the program flow is through the block labelled :x86
because the test echo statements which are put there are run.
Edit 2 :
After following the suggestions from Paul & Co, changed the normal set
command to extended syntax that is with the quotes.
On running the vcvars32.bat the execution stops at the below lines :
@if not "%WindowsSDK_ExecutablePath_x86%" == "" (
@set "PATH=%WindowsSDK_ExecutablePath_x86%;%PATH%"
)
The error shown is:
\Microsoft was unexpected at this time.
I added
\nul
inif exist "%~dp0bin\nul"
to differentiate between file and folder.After the help from @Jeb, I am able to resolve this error using the below tweak in vcvars32.bat.
I added
before
Basically I just stripped the quotes from the PATH variable.
(Indebted to @jeb for his valuable suggestion).