China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 09:00
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Repost: Gold Panning of DOS Commands - Usage of the ECHO Command View 1,997 Replies 8
Original Poster Posted 2002-10-25 00:00 ·  中国 广东 佛山 禅城区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
Gold Panning for DOS Commands - Usage of the ECHO Command
The ECHO command is a sub-command of the well-known DOS batch processing command, 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 turn off the display of the "ECHO OFF" command line itself, you need to add "@" in front of the command line.

2. Display the current ECHO setting status
Format: ECHO

3. Output a prompt message
Format: ECHO message content

The above are the three common usages of the ECHO command, which are also familiar and used by everyone. 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 at the DOS prompt 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 an empty line, which is equivalent to entering a carriage return
Format: ECHO.
It is worth noting that the "." in the command line should be immediately after ECHO without a space in between, otherwise the "." will be output to the screen as a prompt message. Also, the "." can be replaced by any one of the symbols such as,, : ; " / +, etc.

In the following example, the carriage return output by ECHO. is redirected through the DOS pipeline as the input of the TIME command, which is equivalent to giving a carriage return after the TIME command is executed. So when executed, 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 an empty line is: adding ECHO. in the autoexec batch file to make the originally displayed prompt screen at the bottom of the screen appear at the top of the screen.

6. Answer the question in the command
Format: ECHO answer | command file name
The above format can be used to simplify the operation of some commands that require man-machine dialogue (such as CHKDSK/F; FORMAT Drive:; del *.*). It is through the DOS pipeline command that the preset answer output by the ECHO command is used as the input of the man-machine dialogue command. The following example is equivalent to entering "Y" and pressing Enter 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 > file name
ECHO file content >> file name
For example: C:>ECHO @ECHO OFF>AUTOEXEC.BAT to create an autoexec batch file

C:>ECHO C:\CPAV\BOOTSAFE>>AUTOEXEC.BAT to append content to the autoexec batch file

C:TYPE AUTOEXEC.BAT to display the autoexec 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 to hold down the Alt key and type 156 on the numeric keypad. Similar situations are类推:

C:>ECHO +156+42+116>PRN (input the underline command FS*t)

C:>ECHO +155@>PRN (input the initialization command ESC@)

C:>ECHO.>PRN (new line)

9. Make the speaker beep
C:>ECHO ^G

"^G" is input with 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 call.

10. Execute ESC control sequences to modify 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 a 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"←





我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 2 Posted 2002-10-26 00:00 ·  中国 陕西 西安 电信
初级用户
★★
孤胆枪手
Credits 688
Posts 148
Joined 2002-10-26 00:00
23-year member
UID 63
Gender Male
From 陕西
Status Offline
我:╭∩╮(︶︿︶)╭∩╮。靠!!!
Floor 3 Posted 2002-10-26 00:00 ·  加拿大 安大略省 多伦多
初级用户
Credits 107
Posts 3
Joined 2002-10-26 00:00
23-year member
UID 64
Gender Male
Status Offline
Well, how did you figure it out? Impressive.
Floor 4 Posted 2002-10-26 00:00 ·  中国 江西 吉安 电信
高级用户
★★
Credits 667
Posts 135
Joined 2002-10-25 00:00
23-year member
UID 62
Gender Male
Status Offline
good. Keep it up!
================================= kickout
大功告成,打个Kiss!
Floor 5 Posted 2003-05-27 00:00 ·  中国 吉林 四平 中移铁通
初级用户
蝎蛇统领
Credits 280
Posts 35
Joined 2003-05-21 00:00
23-year member
UID 2294
Gender Male
Status Offline
That's really high! How did you find it?
我是菜鸟,我要变成老鸟!
www.10.164.63.101.com
Floor 6 Posted 2003-06-08 00:00 ·  中国 北京 世纪互联数据中心
初级用户
Credits 167
Posts 24
Joined 2003-06-07 00:00
23-year member
UID 4108
Gender Male
Status Offline
Thank you so much, I was just looking for these articles!!
家驹学电脑-http://BeyondPC.3322.Net,您永远的朋友!!


走自己的路,让别人去说吧!
Floor 7 Posted 2003-08-20 00:00 ·  中国 广东 广州 电信
中级用户
Credits 386
Posts 48
Joined 2003-06-29 00:00
22-year member
UID 6106
Gender Male
Status Offline
Learned another good thing again
Floor 8 Posted 2003-08-20 00:00 ·  中国 湖北 武汉 联通
银牌会员
★★★
Credits 1,681
Posts 512
Joined 2003-08-02 00:00
22-year member
UID 7953
Gender Male
Status Offline

@ECHO”←


It doesn't seem to work, tried it in VMWare
Somehow somewhere I've got to choose.
No matter if it is win or lose.
Floor 9 Posted 2003-09-26 00:00 ·  中国 广东 广州 天河区 电信
初级用户
Credits 133
Posts 6
Joined 2003-09-26 00:00
22-year member
UID 10370
Gender Male
Status Offline
No problem. I'm playing DOS under WIN98.
Forum Jump: