Suppress Command Printing in MS-DOS Batch Files
In MS-DOS 6.22, batch scripts display every executed command on the screen by default through a feature known as command echoing. To create clean, professional script output, this behavior can be disabled globally or per command using built-in DOS directives. This guide explains the exact commands used to suppress command printing, how to hide the suppression command itself, and how to silence individual lines within a batch file.
The Command: ECHO OFF
The standard command to suppress command printing in MS-DOS 6.22 batch mode is:
ECHO OFF
When ECHO OFF is executed, MS-DOS stops printing
subsequent batch commands to the screen before running them. However,
standard program output (such as text generated by utility programs or
ECHO [message] statements) will still be displayed.
Silencing the Suppress Command: @ECHO OFF
Running ECHO OFF by itself causes the line
ECHO OFF to print on the screen before the suppression
takes effect. To prevent this, prefix the command with the at symbol
(@):
@ECHO OFF
In MS-DOS, the @ symbol suppresses the display of the
specific command it precedes. Placing @ before
ECHO OFF ensures that not even the initial configuration
command appears in the console. This is typically placed as the very
first line of any batch script.
Example Usage
Here is a standard comparison of batch behavior:
Default Behavior (Commands Displayed)
DIR C:\
PAUSE
Output: Prints DIR C:\, executes the directory
listing, prints PAUSE, then prompts "Press any key to
continue . . .".
Suppressed Behavior (Clean Output)
@ECHO OFF
DIR C:\
PAUSE
Output: Executes the directory listing and prompts "Press
any key to continue . . ." without printing the lines
DIR C:\ or PAUSE.
Suppressing Single Lines
If you want to keep command echoing enabled for the majority of a
script but hide only one or two specific lines, place the @
character at the beginning of those lines instead of using
ECHO OFF:
@COPY C:\FILE.TXT D:\BACKUP.TXT
Silencing Command Output vs. Command Printing
ECHO OFFsuppresses the batch interpreter from printing the commands themselves.> NULsuppresses the output generated by a command.
To hide both the command and any text it generates, combine both techniques:
@COPY C:\FILE.TXT D:\ > NUL