2

When I copy/paste the lines below into a cmd window it executes without a problem.

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
msbuild proj\projsln /p:Configuration=Debug 
proj\proj\bin\Debug\proj.exe my args

However when I save it as DoStuff.bat I get the message below (which is the text from executing vcvars32.bat), then nothing else. It does not build my project and obviously doesn't run the newly built executable.

Why doesn't it and how do I have it run all three commands?

>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
Vik David
  • 3,640
  • 4
  • 21
  • 29
  • 1
    Possible duplicate of [Why does only the first line of this Windows batch file execute but all three lines execute in a command shell?](http://stackoverflow.com/questions/4036754/why-does-only-the-first-line-of-this-windows-batch-file-execute-but-all-three-li) – user Nov 29 '16 at 19:04

2 Answers2

10

Use CALL to call another batch file.

Kevin K
  • 9,344
  • 3
  • 37
  • 62
vulkanino
  • 9,074
  • 7
  • 44
  • 71
  • 1
    For those confused, the reason why this is needed in this case is because the script is calling another script. The `call` command is needed to let windows know it needs to continue executing the original script when the second script is complete: `Calls one batch program from another without stopping the parent batch program` – lightswitch05 Aug 22 '13 at 12:31
0

Well, there has to be a reason it isn't continuing. Is it that the command is waiting for some input? Thats all that I can think of. Try re-directing the output of the batch file to a log and see what is going on.

Alternatively, split the batch file into separate batch files and put a CALL before each call to the batch file.

Frankline
  • 40,277
  • 8
  • 44
  • 75