简体   繁体   中英

Looping a batch file that calls another batch file

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM