Windows command line not executing multiple commands

280 views Asked by At

I am building a visual studio project through command line for that I need to run multiple commands at once.So I am created a batch file which includes all the commands.When I run the batch file only first command is executed.My batch file is given below

test.bat

C:
cd C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Auxiliary\Build 
vcvarsall.bat x86_amd64
devenv D:\Jenkins\cpputest-master\cpputest-master\CppUTest.sln /Build
D:
cd D:\Jenkins\cpputest-master\cpputest-master\cpputest_build
mv AllTests.exe D:\Jenkins\jenkinsHome\workspace\TestCppUTest
cd D:\Jenkins\jenkinsHome\workspace\TestCppUTest
AllTests.exe -ojunit

When I run this batch file first three commands are executed,fourth command is not executed.But if I run these commands using && all the commands are executed.Any suggestions??

1

There are 1 answers

9
AudioBubble On BEST ANSWER

If you call a batch file from within a batch file, you need to use call otherwise your calling batch file will be terminated.

So instead of

vcvarsall.bat x86_amd64

you need to use:

call vcvarsall.bat x86_amd64

If devenv is also a batch file, then it needs to be replaced with call devenv as well.