从批处理文件返回控制权
我有一个批处理文件,其中包含以下几个命令;
XCOPY
DEL
RMDIR
anotherBatch.bat
XCOPY
DEL
RMDIR
正如您所看到的,在这之间有一个对另一个批处理文件(anotherBatch.bat)的调用,它执行一些其他处理。
现在我的问题是,执行 anotherBatch 后,控件永远不会返回到原始批处理文件,并且只是在那里结束。
如何确保控制权返回?
I have a batch file which has several commands as follows;
XCOPY
DEL
RMDIR
anotherBatch.bat
XCOPY
DEL
RMDIR
As you can see, in between there is a call to another batch file (anotherBatch.bat), which does some other processing.
Now my question is after anotherBatch gets executed, the control never returns back to the original batch file and it just ends there.
How do I make sure that the control is returned back ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
批处理 SUBROUTINE 是通过 CALL 命令调用的另一个批处理文件:
子例程可以放置在调用代码的同一文件中。这是通过在其名称前加上冒号来指示的:
EXIT /B 命令(不仅仅是 EXIT)用于在同一文件中标记子例程结束;主程序也必须这样做。
如果在没有 CALL 命令的情况下调用另一个批处理文件(如您的示例中所示),则最终结果类似于“转到另一个文件”:当调用的文件结束时,进程将在该点结束。我曾经将这样的批处理文件称为“覆盖”(而不是“子例程”)。
A Batch SUBROUTINE is another Batch file called via CALL command:
The subroutine may be placed in the same file of the calling code. This is indicated by preceding its name with colon:
The EXIT /B command (NOT just EXIT) is used to mark the subroutine end in the same file; this must also be done for the main program.
If another Batch file is invoked with no CALL command, as in your example, the net result is similar to a "GOTO to another file": when the invoked file ends, the process ends at that point. I used to call "Overlay" (instead of "subroutine") a Batch file called this way.
您应该显式调用另一个批处理文件
you should explicitly call the other batch file