Usage of the ECHO Command in DOS Commands
The ECHO command is a sub - command of the DOS batch processing commands that everyone is familiar with, but some of its functions and usages may not all be known to you. Just take a look:
1. As a switch to control whether the command line itself is displayed when the batch processing command is executed
Format: ECHO
If you want to close the display of the "ECHO OFF" command line itself, you need to add "@" before this command line.
2. Display the current ECHO setting status
Format: ECHO
3. Output prompt information
Format: ECHO information content
The above are the three common usages of the ECHO command, and they are also what everyone is familiar with and can use. But as a gold digger of DOS commands, you should also know the following skills:
4. Turn off the DOS command prompt
Typing ECHO OFF in the DOS prompt state can turn off the display of the DOS prompt, leaving only the cursor on the screen. The prompt will reappear until ECHO ON is typed.
5. Output a blank line, which is equivalent to entering a carriage return
Format: ECHO.
It should be noted that the "." in the command line should be immediately after ECHO without a space in between, otherwise the "." will be regarded as prompt information and output to the screen. In addition, the "." can be replaced by any one of symbols such as,,:;"/+.
In the following example, the carriage return output by ECHO. is transferred through the DOS pipe as the input of the TIME command, which is equivalent to giving a carriage return after the TIME command is executed. So when executing, the system will automatically return to the DOS prompt state after displaying the current time:
C:>ECHO.|TIME
Another application example of the ECHO command outputting a blank line is: adding ECHO. in the auto - batch file, so that the originally displayed prompt screen at the bottom of the screen appears at the top of the screen.
6. Answer the question in the command
Format: ECHO answer|command filename
The above format can be used to simplify the operation of some commands that need man - machine dialogue (such as CHKDSK/F; FORMAT Drive:; del *.*). It is to use the DOS pipe command to take the preset answer output by the ECHO command as the input of the man - machine dialogue command. The following example is equivalent to entering "Y" and pressing the carriage return when the called command has a man - machine dialogue:
C:>ECHO Y|CHKDSK/F
C:>ECHO Y|DEL A :*.*
7. Create a new file or add content to a file
Format: ECHO file content>filename
ECHO file content>>filename
For example: C:>ECHO @ECHO OFF>AUTOEXEC.BAT to create an auto - batch file
C:>ECHO C:\CPAV\BOOTSAFE>>AUTOEXEC.BAT to append content to the auto - batch file
C:TYPE AUTOEXEC.BAT to display the auto - batch file
@ECHO OFF
C:\CPAV\BOOTSAFE
8. Output print content or print control codes to the printer
Format: ECHO printer control code>PRN
ECHO print content>PRN
The following example is to input print control codes to the M - 1724 printer. <Alt>156 is pressing the Alt key and typing 156 on the numeric keypad. The same situation can be deduced by analogy:
C:>ECHO <Alt>+156<Alt>+42<Alt>+116>PRN (input the underline command FS*t)
C:>ECHO <Alt>+155@>PRN (input the initialization command ESC@)
C:>ECHO.>PRN (new line)
9. Make the speaker beep
C:>ECHO ^G
"^G" is input by Ctrl+G or Alt+007. Entering multiple ^G can produce multiple beeps. The usage is to directly add it to the batch file or make a batch file to call.
10. Execute the ESC control sequence to modify the screen and keyboard settings
We know that the device driver ANSI.SYS of DOS provides a set of ESC control sequences for modifying screen and keyboard settings. For example, executing the batch program with the following content can define the function key F12 as the DOS command "DIR/W" and modify the screen color to white characters on a blue background.
@ECHO"←
———————————————
Transferred from Feedback & User Communication
Obviously posted in the wrong section, deduction for points is processed
——Administrator
———————————————
The ECHO command is a sub - command of the DOS batch processing commands that everyone is familiar with, but some of its functions and usages may not all be known to you. Just take a look:
1. As a switch to control whether the command line itself is displayed when the batch processing command is executed
Format: ECHO
If you want to close the display of the "ECHO OFF" command line itself, you need to add "@" before this command line.
2. Display the current ECHO setting status
Format: ECHO
3. Output prompt information
Format: ECHO information content
The above are the three common usages of the ECHO command, and they are also what everyone is familiar with and can use. But as a gold digger of DOS commands, you should also know the following skills:
4. Turn off the DOS command prompt
Typing ECHO OFF in the DOS prompt state can turn off the display of the DOS prompt, leaving only the cursor on the screen. The prompt will reappear until ECHO ON is typed.
5. Output a blank line, which is equivalent to entering a carriage return
Format: ECHO.
It should be noted that the "." in the command line should be immediately after ECHO without a space in between, otherwise the "." will be regarded as prompt information and output to the screen. In addition, the "." can be replaced by any one of symbols such as,,:;"/+.
In the following example, the carriage return output by ECHO. is transferred through the DOS pipe as the input of the TIME command, which is equivalent to giving a carriage return after the TIME command is executed. So when executing, the system will automatically return to the DOS prompt state after displaying the current time:
C:>ECHO.|TIME
Another application example of the ECHO command outputting a blank line is: adding ECHO. in the auto - batch file, so that the originally displayed prompt screen at the bottom of the screen appears at the top of the screen.
6. Answer the question in the command
Format: ECHO answer|command filename
The above format can be used to simplify the operation of some commands that need man - machine dialogue (such as CHKDSK/F; FORMAT Drive:; del *.*). It is to use the DOS pipe command to take the preset answer output by the ECHO command as the input of the man - machine dialogue command. The following example is equivalent to entering "Y" and pressing the carriage return when the called command has a man - machine dialogue:
C:>ECHO Y|CHKDSK/F
C:>ECHO Y|DEL A :*.*
7. Create a new file or add content to a file
Format: ECHO file content>filename
ECHO file content>>filename
For example: C:>ECHO @ECHO OFF>AUTOEXEC.BAT to create an auto - batch file
C:>ECHO C:\CPAV\BOOTSAFE>>AUTOEXEC.BAT to append content to the auto - batch file
C:TYPE AUTOEXEC.BAT to display the auto - batch file
@ECHO OFF
C:\CPAV\BOOTSAFE
8. Output print content or print control codes to the printer
Format: ECHO printer control code>PRN
ECHO print content>PRN
The following example is to input print control codes to the M - 1724 printer. <Alt>156 is pressing the Alt key and typing 156 on the numeric keypad. The same situation can be deduced by analogy:
C:>ECHO <Alt>+156<Alt>+42<Alt>+116>PRN (input the underline command FS*t)
C:>ECHO <Alt>+155@>PRN (input the initialization command ESC@)
C:>ECHO.>PRN (new line)
9. Make the speaker beep
C:>ECHO ^G
"^G" is input by Ctrl+G or Alt+007. Entering multiple ^G can produce multiple beeps. The usage is to directly add it to the batch file or make a batch file to call.
10. Execute the ESC control sequence to modify the screen and keyboard settings
We know that the device driver ANSI.SYS of DOS provides a set of ESC control sequences for modifying screen and keyboard settings. For example, executing the batch program with the following content can define the function key F12 as the DOS command "DIR/W" and modify the screen color to white characters on a blue background.
@ECHO"←
———————————————
Transferred from Feedback & User Communication
Obviously posted in the wrong section, deduction for points is processed
——Administrator
———————————————
Recent Ratings for This Post
( 1 in total)
Click for details
| Rater | Score | Time |
|---|---|---|
| DOSroot | -2 | 2008-12-25 18:19 |

