蝙蝠文件终止 [英] Bat file termination

查看:160
本文介绍了蝙蝠文件终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑两个 bat 文件.

echo Before
inner.bat
echo After

inner.bat

echo Inner
goto :eof

当我执行 outer.bat 时,不会回显之后".因此,内部脚本中的"goto:eof" 终止了外部脚本.

When I execute outer.bat "After" is not echoed. So "goto :eof" in the inner script terminates the outer script.

我可以在不修改 inner.bat 的情况下调用 inner.bat 后重写 outer.bat 以继续执行吗?

Can I rewrite outer.bat to continue execution after calling inner.bat without modifying inner.bat?

推荐答案

批处理文件具有单个执行上下文.当您像这样嵌套批处理文件调用时,嵌套文件将完全替换外部/父批处理文件的上下文.没有记录表明存在父批处理文件,因此您只需在内部文件完成后返回提示即可.

Batch files have a single execution context. When you nest batchfile calls like that, the nested file completely replaces the outer/parent batch file's context. There's no record saying that there was a parent batch file, so you simply return to the prompt when the inner file completes.

要能够返回外部批处理文件,您必须

To be able to return to the outer batch file, you have to do

 echo Before
 call inner.bat
 echo After

这篇关于蝙蝠文件终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆