cmd.exe:何时使用调用来运行外部程序
似乎包含以下内容的 cmd 脚本
prog1
prog2
?
call prog1
call prog2
与使用 CALL 命令有何意义
It seems that a cmd script containing:
prog1
prog2
does the same as
call prog1
call prog2
What is the point of using the CALL command ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您想要执行以下任一操作时,应该使用
call
:包含以下行的命令文件:
将链接到
number2.cmd
文件,这意味着它将运行该脚本,但不会返回以继续执行当前脚本。对于第二点,您可以执行以下操作:
您将在
in here
中打印两次。这种在命令脚本中调用函数的能力实际上非常方便。You should use
call
when you either want to:A command file with the line:
will chain to the
number2.cmd
file, meaning it will run that script but not return to continue execution on the current one.As to the second point, you can do things like:
and you will get
in here
printed twice. This ability to call functions within command scripts is actually quite handy.当您需要调用另一个批处理程序(cmd 脚本)时,您应该使用
call
。如果prog1
是可执行文件,则使用“call”将不起作用。 (prog1.exe
)例如,如果您有两个脚本:
并且在
cmd1.cmd
中您有一行:... 那么您的脚本将在以下情况下立即停止 :
cmd2.cmd
执行完毕。相反,你应该使用:You should use
call
when you need to call another batch program (cmd script). Using 'call' will have no effect ifprog1
is an executable file. (prog1.exe
)If you, for example, have two scripts:
And within
cmd1.cmd
you have a line:... then your script will stop as soon as
cmd2.cmd
is finished executing. Instead you should use:通常,调用用于运行一个批处理文件中的另一个批处理文件。当调用的批处理文件完成时,原始批处理文件的其余部分也完成。
请注意,如果批处理文件不存在,则会给出错误消息。
语法是:
CALL [drive:][path]filename [batch-parameters]
在哪里调用它没有限制。您可以在任何批处理文件中使用 CALL 命令来调用另一个批处理文件。
希望这有帮助。
Normally call is used to run another batch file within a batch file. When the batch file that is called is completed, the remainder of the original batch file is completed.
Note if the batch file does not exist it will give an error message.
syntax is:
CALL [drive:][path]filename [batch-parameters]
There are no restriction in where to call it. You can use CALL command in any batch file to call another batch file.
Hope this helps.