@echo on
Here all functions of ECHO explained:
@echo [on/off] (to set the command-line settings)
echo [text] (to print text to the screen)
echo. (to print an empty line to the screen)
echo (displays the current setting of the command-line)
echo /? (displays help for the command ECHO)
I hope I was able to help you.
–
–
–
–
By default, every command executed in a batch file is also echoed to the output - not just the output of the command, but the command itself.
The echo command has three modes:
When called with some arguments AFTER a space, it will output the arguments.
When called as echo.
(no space) it will output just a blank line.
When called with just the arguments on or off, it controls the behaviour of printing the commands as they execute.
So, the echo off
command turns off the output at the start of the batch file. However, that command itself is still echoed before it has a chance to turn off the echoing. The @ symbol has the effect of turning off the output for only the current command.
Combining the two, the @echo off
at the start of a batch file turns off the echoing without itself being echoed.
It follows from this that if you try to echo just the word off
, without quotes, it will turn off command printing instead. If you try to work around this by quoting the word "off"
, the output will include the quotes.
The answer, thanks to @JeffZeitlin's comment below, is:
In the presumably unusual case of wanting to echo just the word off or on (i.e., not a part of any other string), it turns out that echo.off and echo.on do the trick.
–
–
–
Partial answer is this: What does "@" mean in Windows batch scripts
The @ before the command means do not print that command when running it.
The off argument tells the script not output any other commands, however without the @ would output the echo off (since echoing hasn't yet been turned off)
The on argument turns command echoing back on.
Any other arguments are just echoed to the display
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.