Display messages on screen, turn command-echoing on or off.
Syntax ECHO [ON | OFF] ECHO [message] ECHO /? @ command Key ON : Display each line of the batch on screen (default). OFF : Only display the command output on screen. message : a string of characters to display. @ : Turn off ECHO for the current line only. ? : Display help.
Type ECHO without parameters to display the current echo setting
(ON or OFF).
In most batch files you will want ECHO OFF, turning it ON can be useful when
debugging a problematic batch script.
In a batch file, the @ symbol at the start of a line is the same as ECHO OFF applied to the current line only.
Normally a command is executed and takes effect from the next line onwards, @ is a rare example of a command that takes effect immediately.
ECHO does not set or clear the Errorlevel.
ECHO is an internal command.
Command characters will normally take precedence over the ECHO statement
e.g. The redirection and pipe characters: & < > | ON OFFTo override this behaviour you can escape each command character with ^ or : as follows:
ECHO Nice ^&Easy ECHO Salary is ^> Commision ECHO Name ^| Username ^| Expiry Date ECHO:Off On Holiday ECHO: /? Will display helpAn alternative approach is to use SET /P which will display the string without interpreting anything.
C:\> <nul set/p "_any_variable=string to emit" e.g. C:\> <nul (set/p "_demo=This & That ^more < or > less") This & That ^more < or > less
The general syntax is:
Echo This is some Text > FileName.txtTo avoid extra spaces:
Echo Some more text>FileName.txtAn alternative (undocumented) syntax:
>FileName.txt Echo Some more textTo create an empty (zero byte) file:
Echo: 2>EmptyFile.txtWith all these commands, you may also want to append to an existing file using the >> redirection operator.
To display a department variable:
ECHO %_department%
A more robust alternative is to separate with : or ( instead of a space.ECHO:%_department%
Using a colon like this will sanitise the values ON /OFF /? so for example
Set "_var=OFF"
Echo %_var%
Will will actually turn Echo offEcho:%_var%
Will simply display "OFF"Using Echo:in this way does have some limitations:
- If the variable does not exist, ECHO: will return the variable name"%_var%"
- If you are using DelayedExpansion (!_var!) AND the syntax to search and replace parts of a variable or display substrings of a variable, then the Echo:syntax will not work. You can workaround this by using an intermediate variable or just reverting to the default parse time expansion of variables.
There are some edge cases (such as adding \..\..\..\..\ to a variable) where only ( will work without errors e.g. Echo(%var%
Use the TYPE command.
The following command in a batch file will trigger the default beep on most PC’s
ECHO ^G
To type the BELL character use Ctrl-G or 'Alt' key, and 7 on the numeric keypad. (ascii 7)
The default beep is now played through the speakers/audio system, however if you select the 'No Sounds' scheme in Contol Panel ➞ Sounds ➞ Change system sounds, then the default beep will not play.
Alternatively using Windows Media Player:
START/min "C:\Program Files\Windows Media Player\wmplayer.exe" %windir%\media\chimes.wavUsing PowerShell, the numbers select frequency and duration:
powershell.exe "[console]::beep(850,300)"
Produce a System Beep by forcing a non-breaking error in the CHOICE command:
Echo 1n| CHOICE /N >nul 2>&1 & rem BEL
To produce an empty line, without displaying the echo status, use the Echo command immediately followed with a colon (delimiter):
Echo First Line
Echo:
Echo Third line
This can also be written as
Echo First Line & Echo: & Echo Third lineSeveral other delimiter characters will produce the same effect ; ( / + =
Other command delimiters are available but have buggy side effects, for example Echo. will search for a file named "echo" (or echo.exe) in the current directory, if such a file is found that will raise an error. If the 'echo' file does not exist then the command does work, but this still makes Echo. slightly slower than echo: (In recent builds of WIndows 10 Echo. will always throw an error.)
To ECHO text without including a CR/LF (source)
<nul (set/p _any_variable=string to emit)
Extended ASCII box-characters can be used to display characters inside a box, this will work in the most common code pages, but you do need to ensure the batch file is encoded as ANSI, many text editors will automatically switch to unicode.
Echo Off Echo: Echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ Echo ³ ³ Echo ³ Hello this will appear inside a box ³ Echo ³ ³ Echo ³ ³ Echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Echo: Pause
To view each item in the path on a single line, this works by replacing the semicolons with newlines:
ECHO:%PATH:;= & ECHO:%
Streams allow one file to contain several separate forks of information, like the macintosh resource fork.
The general syntax is:
Echo Text_String > FileName:StreamName
Only the following commands support the File:Stream syntax - ECHO, MORE, FOR
Creating streams:
Echo This is stream1 > myfile.dat:stream1 Echo This is stream2 > myfile.dat:stream2
More < myfile.dat:stream1 More < myfile.dat:stream2 FOR /f "delims=*" %%G in (myfile.dat:stream1) DO echo %%G FOR /f "delims=*" %%G in (myfile.dat:stream2) DO echo %%G
A data stream file can be successfully copied and renamed despite the fact that most applications and commands will report a zero length file. The file size can be calculated from remaining free space. The file must always reside on an NTFS volume.
“The only thing that helps me pass the time away; is knowing I’ll be back at Echo Beach some day” ~ Martha and the Muffins
ANSI colors - Use ANSI colours in the terminal.
SET - Create and display environment variables.
TYPE - Display the contents of a text file.
Banner.cmd - Batch file to display a string of text in extra large letters.
NET SEND %COMPUTERNAME%
SoundRecorder.exe - Record.
Q177795 - Large vs Small fonts.
Q901115 -
Terminal Services/Citrix client makes beep sounds.
Equivalent PowerShell cmdlet: Write-Host
Equivalent bash command: echo - Display message on screen.