在Windows批处理中调用和cmd / c之间的区别 [英] Difference between call and cmd /c in windows batch

查看:1342
本文介绍了在Windows批处理中调用和cmd / c之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释

call someBatchFile.bat ...

cmd /C someBatchFile.bat ...

他们都建议我作为这个问题,但我不明白为什么他们都工作,更重要的是,如果有任何重大差异,我必须知道。

They both were suggested to me as solutions to this problem, but I don't understand why they both work, and more importantly, if there are any significant differences I must be aware of.

推荐答案

不同的是调用执行另一个批处理文件在同一上下文中,因此它们共享相同的环境变量和其他状态(例如 echo ON / OFF 或延迟扩展) code> cmd / C 在完全独立的上下文中执行另一个批处理文件,因此在调用的批处理文件中所做的任何更改不会反映在原始文件中。

The difference is that call execute the other Batch file in the same context of the caller program, so they share the same environment variables and other status (like echo ON/OFF or delayed expansion), whereas cmd /C execute the other Batch file in an entirely separated context, so any change made in the called Batch file is not reflected in the original file.

就像个人说明一样,我用来命名内部子程序通过调用调用的批处理文件$ c>和通过 cmd / C (和 overlay 直接调用的批处理文件调用的外部子程序 调用 cmd / C ,继承调用程序批处理文件的行为和上下文)。

Just as a personal note, I used to name internal subroutine the Batch file invoked via call, and external subroutine the one invoked via cmd /C (and overlay the Batch file directly invoked without call nor cmd /C, that inherits the behavior and context of the caller Batch file).

这篇关于在Windows批处理中调用和cmd / c之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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