路径中带有空格和括号的CALL
下面给出的代码摘录自vcvarsall.bat
文件,该文件用于
设置Visual C ++命令行的环境变量.
由于存在错误(在代码中称为REM语句),因此未设置环境变量.
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
由于未设置环境变量,因此在构建nmake项目时遇到了运行时错误.
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.
有人可以建议一种解决方法,用于在路径中使用空格和括号来调用call
吗?
Could anyone suggest a workaround for calling the call
with spaces and parentheses in the path?
我在被调用的vcvars32.bat文件的开头放置了一个测试echo
语句.如果文件已运行,则该语句应已在屏幕上打印该语句的状态下执行.此外,我确信程序流是通过标记为:x86
的块执行的,因为放置在其中的测试echo语句已运行.
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.
在遵循了Paul& Paul的建议之后Co,将普通的set
命令更改为带引号的扩展语法.
在运行vcvars32.bat时,执行在以下几行停止:
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%"
)
显示的错误是:
\Microsoft was unexpected at this time.
在@Jeb的帮助下,我可以使用 在vcvars32.bat中进行调整.
After the help from @Jeb, I am able to resolve this error using the below tweak in vcvars32.bat.
我添加了
@set PATHTEMP=%PATH%
@set PATH=%PATHTEMP:"=%
之前
@if not "%WindowsSDK_ExecutablePath_x86%" == "" (
@set "PATH=%WindowsSDK_ExecutablePath_x86%;%PATH%"
)
基本上,我只是从PATH变量中删除了引号.
Basically I just stripped the quotes from the PATH variable.
(感谢@jeb的宝贵建议).
(Indebted to @jeb for his valuable suggestion).