Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run nmake in one bat file

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.

like image 897
Dean Chen Avatar asked Dec 13 '25 17:12

Dean Chen


1 Answers

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.

like image 156
LS_ᴅᴇᴠ Avatar answered Dec 16 '25 01:12

LS_ᴅᴇᴠ



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!