简体   繁体   English

循环调用另一个批处理文件的批处理文件

[英]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. 我的嵌入式C编译器生成一个批处理文件,以从命令行在处理器模拟器中运行各种构建输出。 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. 当我按Enter键时,脚本结束,并且从不执​​行goto。 If I remove the pause statement the script just ends immediately. 如果删除暂停语句,脚本将立即结束。 If I type & goto repeat the script still ends immediately. 如果我键入&goto重复,脚本仍将立即结束。

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. 从命令行CD到批处理文件,运行它,然后单击向上箭头并有效地输入即可完成我想要的工作……我试图将其自动化一点。

To run a batch file from another batch file, you have to use the call statement. 要从另一个批处理文件运行一个批处理文件,必须使用call语句。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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