几种从另外一个或提示调用Windows批处理文件。哪一个在这种情况下? [英] Several ways to call a windows batch file from another one or from prompt. Which one in which case?
问题描述
Windows批处理文件( called.bat
或 called.cmd
)可以从另一个批处理文件被调用( caller.bat
或 caller.cmd
),或在几个方面交互式cmd.exe提示:
- 直接调用:
called.bat
- 使用call命令:
呼叫called.bat
- 使用cmd命令:
CMD / C called.bat
- 使用start命令:
启动called.bat
我挺麻烦根据他们的帮助文字来区分他们的使用目的:当使用哪一个?例如为什么我会用'叫'命令,而不是直接调用。有什么不同?
我很感兴趣的一些总结报告的分析从不同角度的看法所有4种可能性(和其他人如有丢失):为他们设计适合推荐的使用情况下,产卵过程中,执行上下文,环境,回报$ C $ç处理。
请注意:我使用Windows XP SP3
-
该批处理文件将通过当前的cmd.exe实例来执行(或新的cmd.exe例如,如果,例如,双击在资源管理器)。
-
同#1,只有拥有一批/ CMD文件内使用时的效果。在一个批处理文件,没有'来电',父批处理文件结束,控制传递给名为批处理文件;与'呼'运行孩子批处理文件,父批处理文件继续下面的调用语句。
-
运行在一个新的CMD.EXE实例的批处理文件。
-
开始将运行在一个新窗口,新的cmd.exe实例的批处理文件,调用者不会等待完成。
A windows batch file (called.bat
or called.cmd
) can be called from another batch file (caller.bat
or caller.cmd
) or interactive cmd.exe prompt in several ways:
- direct call:
called.bat
- using call command:
call called.bat
- using cmd command:
cmd /c called.bat
- using start command:
start called.bat
I'm quite in trouble to differentiate their intended usage based on their help text: when to use which one? e.g. why I might use 'call' command instead of direct call. What's different?
I'm interested on some summary report that analyze all 4 possibilities (and others if any missing) from various point of views: recommended use cases for which they are designed to fit, process spawning, execution context, environment, return code processing.
Note: I'm using Windows XP SP3.
The batch file will be executed by the current cmd.exe instance (or a new cmd.exe instance if, for instance, double-clicked in Explorer).
Same as #1, only has an effect when used inside a batch/cmd file. In a batch file, without 'call', the parent batch file ends and control passes to the called batch file; with 'call' runs the child batch file, and the parent batch file continues with statements following call.
Runs the batch file in a new cmd.exe instance.
Start will run the batch file in a new cmd.exe instance in a new window, and the caller will not wait for completion.
这篇关于几种从另外一个或提示调用Windows批处理文件。哪一个在这种情况下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!