183

I saw @ is used in such contexts:

@echo off

@echo start eclipse.exe

What does @ mean here?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Baiyan Huang
  • 6,463
  • 8
  • 45
  • 72

9 Answers9

254

It means not to output the respective command. Compare the following two batch files:

@echo foo

and

echo foo

The former has only foo as output while the latter prints

H:\Stuff>echo foo 
foo

(here, at least). As can be seen the command that is run is visible, too.

echo off will turn this off for the complete batch file. However, the echo off call itself would still be visible. Which is why you see @echo off in the beginning of batch files. Turn off command echoing and don't echo the command turning it off.

Removing that line (or commenting it out) is often a helpful debugging tool in more complex batch files as you can see what is run prior to an error message.

Joey
  • 344,408
  • 85
  • 689
  • 683
45

It means "don't echo the command to standard output".

Rather strangely,

echo off

will send echo off to the output! So,

@echo off

sets this automatic echo behaviour off - and stops it for all future commands, too.

Source: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true

Jeremy McGee
  • 24,842
  • 10
  • 63
  • 95
33

By default, a batch file will display its command as it runs. The purpose of this first command which @echo off is to turn off this display. The command "echo off" turns off the display for the whole script, except for the "echo off" command itself. The "at" sign "@" in front makes the command apply to itself as well.

Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186
  • 3
    I can't see any more or better information in your post, like in the other 5 year old posts. – jeb Oct 20 '16 at 11:53
  • 4
    For me, this was more understandable. – Arash Dec 20 '20 at 04:55
  • 1
    @Arash, same for me. The other answers fail to mention that the [execution of] the batch file will show the commands as it runs and that `echo off` will turn off this feature, which is essential to understanding the use of the additional **@**. – Mehdi Charife Nov 22 '22 at 18:55
14

The @ disables echo for that one command. Without it, the echo start eclipse.exe line would print both the intended start eclipse.exe and the echo start eclipse.exe line.

The echo off turns off the by-default command echoing.

So @echo off silently turns off command echoing, and only output the batch author intended to be written is actually written.

sarnold
  • 102,305
  • 22
  • 181
  • 238
13

It inherits the meaning from DOS.

From the '@' section of Technical Notes > Programming > Batch File Commands (archived version):

@: In DOS version 3.3 and later, hides the echo of a batch command. Any output generated by the command is echoed.

The at-sign can be prefixed to any DOS command, program name, or batch file name within a batch file.

Without it, you could turn off command echoing using the echo off command, but that command would be echoed first.

Jim Grisham
  • 384
  • 3
  • 11
Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448
  • 1
    Link is now broken – ojchase Jan 09 '19 at 23:44
  • _(The edit queue is currently full, so I'm putting this here for now.)_ The most recent working 'archive.org' version of the above link _(the original page was last actually edited on 5 March 2006)_ is: [Technical Notes / Programming / Batch File Commands / @ _(archived from the original on 19 November 2016)_](http://web.archive.org/web/20161119150623/http://academic.evergreen.edu/projects/biophysics/technotes/program/batch.htm) – Jim Grisham Oct 21 '22 at 19:12
9

In batch file:

1 @echo off(solo)=>output nothing enter image description here

2 echo off(solo)=> the “echo off” shows in the command line

enter image description here

3 echo off(then echo something) => enter image description here

4 @echo off(then echo something)=> enter image description here

See, echo off(solo), means no output in the command line, but itself shows; @echo off(solo), means no output in the command line, neither itself;

terwxqian
  • 591
  • 6
  • 7
7

Another useful time to include @ is when you use FOR in the command line. For example:

FOR %F IN (*.*) DO ECHO %F

Previous line show for every file: the command prompt, the ECHO command, and the result of ECHO command. This way:

FOR %F IN (*.*) DO @ECHO %F

Just the result of ECHO command is shown.

Aacini
  • 65,180
  • 12
  • 72
  • 108
  • @PsychoData: It is funny that you downvoted the only answer that provide an useful information additional to the other 4 answers that, by the while, already answered the question in the same way... – Aacini Nov 17 '13 at 02:56
  • 6
    I downvoted because it wasn't an answer to his question. You don't even give an explanation of what the @ does. If you have cool examples of usage, great, but it still isn't an answer to his question. You might not also know that I also upvoted the answer with the bet explanation of what it does and where it comes from. I didn't just downvote for no reason. Your "answer" is not an answer. It is a somewhat related statement. – PsychoData Nov 18 '13 at 20:11
3

you can include @ in a 'scriptBlock' like this:

@(
  echo don't echoed
  hostname
)
echo echoed

and especially do not do that :)

for %%a in ("@") do %%~aecho %%~a
walid2mi
  • 2,704
  • 15
  • 15
0

from msdn:

To prevent echoing a particular command in a batch file, insert an @ sign in front of the command. To prevent echoing all commands in a batch file, include the echo off command at the beginning of the file.

dan
  • 1