CALL 命令与带有/WAIT 选项的 START [英] CALL command vs. START with /WAIT option
问题描述
带有 WAIT 选项的 START 命令如何
How is the START command with a WAIT option
START /wait notepad.exe
START /wait notepad.exe
...与使用 CALL 命令有什么不同吗?
...any different from using a CALL command?
CALL notepad.exe
CALL notepad.exe
是否存在一种情况,根据正在执行的内容,一个人的行为可能与另一个人不同?
Is there a situation where one may behave differently that the other dependending on what is being executed?
推荐答案
对于 exe 文件,我认为差异几乎不重要.
但是要启动 exe,您甚至不需要 CALL
.
For exe files, I suppose the differences are nearly unimportant.
But to start an exe you don't even need CALL
.
当开始另一批时,这是一个很大的不同,
因为 CALL
将在同一窗口中启动它,并且被调用的批处理可以访问相同的变量上下文.
所以它也可以改变影响调用者的变量.
When starting another batch it's a big difference,
as CALL
will start it in the same window and the called batch has access to the same variable context.
So it can also change variables which affects the caller.
START
将为被调用的批处理创建一个新的 cmd.exe,如果没有/b,它将打开一个新窗口.
由于是新的上下文,变量不能共享.
START
will create a new cmd.exe for the called batch and without /b it will open a new window.
As it's a new context, variables can't be shared.
使用 start/wait
-
结束时,环境变量的更改丢失
- 调用者等待直到
完成
Using start /wait <prog>
- Changes of environment variables are lost when the <prog>
ends
- The caller waits until the <prog>
is finished
使用调用
- 对于 exe 可以省略,因为它等于只是启动
- 对于 exe-prog,调用者批处理等待或启动 exe 异步,但行为取决于 exe 本身.
- 对于batch文件,调用者批处理继续,当被调用的
完成后,WITHOUT call控件不会返回给调用者批处理
Using call <prog>
- For exe it can be ommited, because it's equal to just starting <prog>
- For an exe-prog the caller batch waits or starts the exe asynchronous, but the behaviour depends on the exe itself.
- For batch files, the caller batch continues, when the called <batch-file>
finishes, WITHOUT call the control will not return to the caller batch
使用 CALL
可以更改参数(对于批处理文件和 exe 文件),但仅限于它们包含插入符号或百分号时.
Using CALL
can change the parameters (for batch and exe files), but only when they contain carets or percent signs.
call myProg param1 param^^2 "param^3" %%path%%
将扩展为(从批处理文件中)
Will be expanded to (from within an batch file)
myProg param1 param2 param^^3 <content of path>
这篇关于CALL 命令与带有/WAIT 选项的 START的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!