1

My embedded C compiler generates a batch file to run various build outputs in a processor simulator from the command line. I'd like to create a batch file to call that auto generated batch file that is somewhere convenient, and I'd like to be able to rerun it just by clicking a key as often as I want all day long.

Here's what I've tried

cd "C:\foo\project name\settings\"
:repeat
cls
"Project Name.Unit Test Ouput.cspy.bat" & pause
goto repeat

I see the output I expect from the batch file, followed by a:

Press any key to continue . . .

When I press enter the script ends and never executes the goto. If I remove the pause statement the script just ends immediately. If I type & goto repeat the script still ends immediately.

CDing to the batch file from the command line, running it, and then click the up arrow and enter effectively does what I want... I am trying to automate it a tiny bit more.

Nick
  • 1,361
  • 1
  • 14
  • 42
  • http://stackoverflow.com/questions/4825746/cmd-exe-when-to-use-call-to-run-external-programs – indiv Jun 19 '15 at 17:37
  • Adding call in front of the batch file call worked like a champ! Can you please post that as the answer so I can accept it? – Nick Jun 19 '15 at 17:45

1 Answers1

2

To run a batch file from another batch file, you have to use the call statement. If you don't, then your outer batch file will end when the inner one does.

call "Project Name.Unit Test Ouput.cspy.bat" & pause
indiv
  • 17,306
  • 6
  • 61
  • 82