Displays or hides the text in batch programs when the program is running. Also indicates whether the command-echoing feature is on or off.
When you run a batch program, the operating system typically displays (echoes) the batch program's commands on the screen. You can turn this feature on or off by using the ECHO command.
ECHO [ON | OFF]
Display a message:
Display a blank line:
For information about suspending the execution of a batch
program, see the PAUSE command.
SET - Create and display environment variables.
TYPE - Display the contents of a text file.
NET SEND %COMPUTERNAME%
Equivalent Linux BASH commands:
echo - Display message on screen.
Command characters will normally take precedence over the ECHO statement e.g. The redirection and pipe characters: & < > | ON OFF
To override this behaviour you can escape each command character with ^:
ECHO Nice ^&Easy ECHO Salary is ^> Commision ECHO Name ^| Username ^| Expiry Date ECHO:Off On Holiday
The ECHO message command is useful when ECHO is off. To display a message that is several lines long without displaying other commands, you can include several ECHO message commands after the ECHO OFF command in your batch program.
If you use the ECHO OFF command on the command-line, the command prompt does not appear on your screen. To redisplay the command prompt, type ECHO ON.
You can insert an at sign (@) in front of a command in a batch program to prevent the operating system from echoing that line.
In v5.0 (and later), to echo a blank line on the screen, you can type ECHO and then a period (ECHO.). There must be no intervening space.
Beginning with v3.30, you could place a period (.), plus (+), slash (/), comma (,), left bracket ([), right bracket (]), or colon (:) immediately after the ECHO command.
Placing a doublequote (") immediately after the ECHO (ECHO") command could echo a blank line.
Prior to v3.30, placing an ALT-255 would echo a blank line.
To display the %PATH% variable:
If the variable does not exist - ECHO will simply return the text "%path%"
You cannot display a pipe (|) or redirection character (< or >) by using the ECHO command.
Shows a batch program that includes a three-line message preceded and followed by a blank line:
ECHO OFF ECHO. ECHO This batch program ECHO formats and checks ECHO new disks ECHO.
If you want to turn ECHO off and you do not want to echo the ECHO command itself, include an at sign (@) before the command:
You can use the IF and ECHO commands on the same command-line:
IF EXIST *.RPT ECHO The report has arrived.