SoFunction
Updated on 2025-04-08

Use of ECHO commands of DOS commands

ECHO command is a subcommand of DOS batch commands that everyone is familiar with, but you may not know all its functions and usages. If you don't believe it, look at it:
1. As a switch that controls whether the batch command displays its own command line when executing.
Format: ECHO [ON|OFF]
If you want to turn off the display of the "ECHO OFF" command line itself, you need to add "@" before the command line.
2. Show the current ECHO setting status
Format: ECHO
3. Output prompt information
Format: ECHO information content
The above are three common uses of ECHO commands, which are also familiar and useful, but as a DOS command gold digger, you should also know the following tips:
4. Close the DOS command prompt
Type ECHO OFF in the DOS prompt state to turn off the display of the DOS prompt so that the screen only has the cursor. The prompt will not reappear until typing ECHO ON.
5. Output a blank line, that is, it is equivalent to inputting a carriage return
Format: ECHO.
It is worth noting that the "." in the command line must follow immediately after ECHO and there must be no spaces, otherwise "." will be output to the screen as a prompt message. In addition, "." can be replaced by any symbol such as:"/[\]+.
In the following example ECHO. The output carriage return is turned into the input of the TIME command via the DOS pipeline, which is equivalent to giving a carriage return after the TIME command is executed. Therefore, when executing, the system will automatically return to the DOS prompt status after displaying the current time:
C:>ECHO.|TIME
Another application example where the ECHO command outputs empty lines is: ECHO. Add it to the automatic batch file to make the prompt screen that was originally displayed at the bottom of the screen appear above the screen.
6. Reply to the question in the order
Format: ECHO reply | Command file name
The above format can be used to simplify the operation of some commands that require human-computer dialogue (such as: CHKDSK/F; FORMAT Drive:; del *.*). It uses the DOS pipeline command to use the preset reply output from the ECHO command as the input of the human-computer dialogue command. The following example is equivalent to entering "Y" to enter the carriage input when the callee's command occurs:
C:>ECHO Y|CHKDSK/F
C:>ECHO Y|DEL A :*.*
7. Create a new file or add file content
Format: ECHO File content>File name
ECHO File content>>File name
For example: C:>ECHO @ECHO OFF>Create automatic batch file
C:>ECHO C:\CPAV\BOOTSAFE>>Add content to the automatic batch file
C:TYPE Displays the automatic batch file
@ECHO OFF
C:\CPAV\BOOTSAFE
8. Output the print content or print the control code to the printer
Format: ECHO Printer Control Code>PRN
ECHO Print content>PRN
The following example is to input a print control code to the M-1724 printer. <Alt>156 is to hold down the Alt key and type 156 on the keyboard, and so on:
C:>ECHO <Alt>+156<Alt>+42<Alt>+116>PRN (Input the underscore command FS*t)
C:>ECHO <Alt>+155@>PRN (Input the initialization command ESC@)
C:>ECHO.>PRN (line break)
9. Make the horn ring
C:>ECHO ^G
"^G" is input with Ctrl+G or Alt+007. Entering multiple ^G can generate multiple sounds. The method of using it is to directly add it to the batch file or make it into a batch file call.
10. Perform ESC control sequence to modify screen and keyboard settings
We know that DOS's device drivers provide a set of ESC control sequences used to modify screen and keyboard settings. If the batch program that executes the following contents, you can define the function key F12 as the DOS command "DIR/W", and modify the screen color to a white character blue background.
@ECHO”←[0;134;”DIR/W”;13p
@ECHO”←[1;37;44m
(Note: The input method of the "←" character in the batch file is to press 27 on the Alt keypad in the edit state)
DOS commands are the first thing people who come into contact with computers need to learn. For many people, they are too familiar and simple. In fact, this is not the case. There are rich contents in these commands, which still need to be further understood and developed. If you are a person with a heart, you will definitely discover new highlights from these self-known commands and gain real money.