Question

When I run the following commands one by one in windows command prompt, they work fine.

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat""
cd C:\\Program Files (x86)\\Jenkins\\jobs\\gdal_win32_develop\\workspace\\codes\\deps\\gdal\\gdal_1.8_rtc
nmake -f makefile.vc clean
nmake -f makefile.vc

When I write them into one bat file and try to execute the bat file in windows command prompt, it only output the first command, the left three commands are not executed.

How to do this? I need this because I want to run it in one Jenkins build project.

Était-ce utile?

La solution

Replace line %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"" with

CALL "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"

You are not aware of it but while typing commands in command line, after first, you got a new instance of cmd.exe and next commands are typed in this new instance. You will need two EXIT commands to exit command prompt.

Typing commands, you could just type "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" instead of %COMSPEC% ..., but in batch it would break batch execution, so you have to prepend CALL.

Autres conseils

Try to use %comspec% /c ..., not %comspec% /k. Look at cmd /? for more help. Moreover, you don't need double backslashes, one is enough.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top