windows 批处理文件中的 at 符号 (@) 是什么,它有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21074863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the at sign (@) in a batch file and what does it do?
提问by n611x007
One remotely familiar with windows/dos batch scripting will recognize this line:
远程熟悉 windows/dos 批处理脚本的人会认出这一行:
@echo off
For many-many days, I was happy with the sentiment that the @
is how echo off
is meant to be written at the top of the batch and that's it.
很多天以来,我对这种感觉@
是如何echo off
写在批次顶部的感觉很满意,仅此而已。
However, recently I've came accrossa line like this:
然而,最近我就翻过这样一行:
@php foo bar
and another linelike this:
而另一条线路是这样的:
@call \network\folder\batch.bat
This reinforced my suspicion that @
has more to it than just echo
mode switching. However @
is not listed in the Windows XP: Command-line reference A-Zwhich I try to use as a reference and thus I'm not sure how to find definitive information on this:
这加强了我的怀疑,@
它不仅仅是echo
模式切换。但是@
没有在Windows XP: Command-line reference AZ 中列出,我尝试将其用作参考,因此我不确定如何找到有关此的明确信息:
What is the @
sign in batch, what's the terminology for it, and what does it do?
@
批处理中的符号是什么,它的术语是什么,它有什么作用?
回答by Sunny
At symbol - @
在符号 - @
The @ symbol
tells the command processor to be less verbose; to only show the output of the command without showing it being executed or any prompts associated with the execution. When used it is prepended to the beginning of the command, it is not necessary to leave a space between the "@" and the command.
该@ symbol
告诉命令处理器要少冗长; 只显示命令的输出而不显示它正在执行或与执行相关的任何提示。使用时,它被添加到命令的开头,“@”和命令之间没有必要留一个空格。
When "echo" is set to "off" it is not necessary to use "@" because setting "echo" to "off" causes this behavior to become automatic. "Echo" is usually set to "on" by default when the execution of a script begins. This is the reason "@echo off" is commonly used, to turn echo off without displaying the act of turning it off.
当“echo”设置为“off”时,不需要使用“@”,因为将“echo”设置为“off”会导致这种行为变得自动。当脚本开始执行时,“Echo”通常默认设置为“on”。这就是通常使用“@echo off”的原因,关闭回声而不显示关闭它的行为。
echo verbose
@echo less verbose
pause
回答by Yuri Constantinoff
Not only does the "at" symbol placed in the beginning hide the command, it can also be used to append command arguments stored in a text file. The syntax is exe@commands (if I remember correctly)
位于开头的“at”符号不仅可以隐藏命令,还可以用于附加存储在文本文件中的命令参数。语法是 exe@commands(如果我没记错的话)