134

One remotely familiar with windows/dos batch scripting will recognize this line:

@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.

However, recently I've came accross a line like this:

@php foo bar

and another line like 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-Z which I try to use as a reference and thus I'm not sure how to find definitive information on this:

What is the @ sign in batch, what's the terminology for it, and what does it do?

Community
  • 1
  • 1
n611x007
  • 8,952
  • 8
  • 59
  • 102
  • 4
    Nothing to add to the ismail answer. But just for future references, the answer is included in the indicated *"Command-line reference A-Z"* documentation under the `Remarks` section of the `echo` command. – MC ND Jan 12 '14 at 14:48
  • 2
    @MCND I see, thanks! Didn't know it was echo-specific... well, I guess I misunderstood the importance of `echo` to batch. Here is the link to [echo#remarks](http://technet.microsoft.com/en-us/library/bb490897.aspx#ECAA). – n611x007 Jan 12 '14 at 18:38
  • 2
    I've heard it called a "squelch", but I only have anecdotal evidence for that. – RustyTheBoyRobot Jan 13 '14 at 19:07
  • 4
    Possible duplicate of [What does "@" mean in Windows batch scripts](http://stackoverflow.com/questions/8486042/what-does-mean-in-windows-batch-scripts) – gunr2171 Feb 16 '17 at 18:02

3 Answers3

197

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.

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 verbose
@echo less verbose
pause
Sunny
  • 7,812
  • 10
  • 34
  • 48
  • 3
    Accepted this one for the on-site explanation of *without* ... *any prompts associated with the execution*, and for saying things like (verbosity of) *the command processor*, and telling about space. :) Nice test batch, too! – n611x007 Jan 12 '14 at 18:43
  • 13
    Apparently this is obvious for everyone but I didn't know that this only works when executed from a `.bat`file, i.e. it doesn't work straight from the command line. – doABarrelRoll721 Feb 22 '16 at 15:11
  • 3
    `When "echo" is set to "off" it is not necessary to use "@" because setting "echo" to "off" causes this behavior to become automatic.` This is true. I have also found that this can cause unwanted side effects. For example - using `@copy` following a `clip < file.txt & pause` command for some reason causes my clipboard to copy the text `1 file copied`. – dgo Sep 25 '16 at 14:19
  • 1
    The bad thing is I can't the official document on it! – Robert Jul 22 '20 at 08:26
0

Not only does the "at" symbol placed in the beginning hide the command, it can, for some commands, also be used to append command arguments stored in a text file. The syntax is exe @commands.txt. armclang.exe for example supports this option.

CivFan
  • 13,560
  • 9
  • 41
  • 58
  • 3
    No, if you try to execute something like `myExe@myCommands` it fails with `is not recognized as an internal or external command` – jeb Dec 10 '19 at 09:56
  • @jeb, What happens when you put spaces around the `@` symbol? I can't get it to work, but I've seen it used in batch files... – SO_fix_the_vote_sorting_bug Aug 13 '20 at 08:55
  • 2
    This is a (possibly common) pattern for Windows exe command-line options. `armclang.exe` supports this command-line option `@ Read command-line options from .` Before finding this message in the help, I, too assumed this was batch code syntax. I guess I'm not accustomed to command-line options starting with `@`. – CivFan Sep 08 '21 at 22:27
  • This is in fact my case. Thanks. – Ziyuan Feb 04 '23 at 10:29
-2

So in simple terms, Mostly imagine this, If we did @echo off, It would've shown echo off right?, Well with @ you can make it so it doesn't show it, Hope this helped!

  • 3
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 21 '22 at 20:54