BAT文件终止 [英] bat-file termination

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

问题描述

考虑两个蝙蝠 -files。

Consider two bat-files.

outer.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.

我可以改写的 outer.bat 的调用后继续执行的 inner.bat 的不修改的 inner.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

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

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