Windows echo Command

Source: Internet
Author: User
Tags echo command echo message

The echo command is a sub-command of a DOS batch command that everyone is familiar with, but some of its features and usage maybe you don't all know, don't believe you see:
1. As a switch that controls whether the batch command displays the command line itself at execution time

Format: ECHO [on| OFF]

If you want to turn off the display of the ECHO off command line itself, you need to precede the command line with "@".

2. Show current echo settings status

Format: ECHO

3. Output hint information

Format: Echo message content

These are the three common uses of the echo command and are familiar to you and will be used, but as a DOS command you should also know the following tips:

4. Close the DOS command prompt

Type echo off at the DOS prompt to turn off the display of the DOS prompt so that the screen leaves only the cursor until you type echo on, and the prompt will appear again.

5. Output a blank line, which is equivalent to entering a carriage return

Format: ECHO.

It is worth noting that in the command line ". "You can't have spaces immediately after echo, otherwise." "will be used as a prompt to output to the screen. In addition ". "Can be used,:;"/[/]+ any symbol instead.

In the example below, Echo. The output carriage return, which is switched by a DOS pipeline as input to the time command, is equivalent to giving a carriage return after the time command executes. Therefore, the system will automatically return to the DOS prompt after the current time is displayed:

c:>echo.| Time

Another example of an application where the echo command outputs a blank line is: Echo. Add in the automatic batch file, so that the original display at the bottom of the screen, appear on the screen.

6. Answer a question in the command

Format: Echo Reply | command file name

The above format can be used to simplify the operation of some commands that require man-machine dialogue (for example: Chkdsk/f;format Drive:;del *. *), which is the input to the man-machine Dialogue command by a DOS pipeline command to output the echo command with a preset reply. The following example is equivalent to entering a "Y" carriage return when a conversation occurs in a invoked command:

C:>echo y| chkdsk/f

C:>echo y| DEL A:*. *

7. Create a new file or add the contents of a file

Format: ECHO file contents > file name

ECHO file contents > > filename

For example: C:>echo @ECHO off>autoexec. BAT to create an automatic batch file

C:>echo c:/cpav/bootsafe>>autoexec. BAT appends content to an automatic batch file

C:type AUTOEXEC. BAT displays the automatic batch file

@ECHO OFF

C:/cpav/bootsafe

8. Output print or print control code to the printer

Format: ECHO Printer control Code >PRN

ECHO Print Content >prn

The following example is a print control code that is entered into the M-1724 printer. <Alt> 156 is to hold down the ALT key on the keypad, type 156, and so on:

C:>echo +156+42+116>prn (Input underline command fs*t)

C:>echo [Email protected]>prn (Input initialization command [email protected])

C:&GT;ECHO.&GT;PRN (line wrapping)

9. To make a horn sound

C:>echo ^g

The "^g" is input with ctrl+g or alt+007, and multiple ^g can be generated to produce multiple beeps. This is done by adding it directly to a batch file or making a batch file call.

10. Perform ESC control sequence modify screen and keyboard settings

We know that the DOS device driver Ansi.sys provides a set of ESC control sequences to modify the screen and keyboard settings. A batch program that performs the following can define the function key F12 as the DOS command "dir/w" and change the screen color to a white character blue background.

@ECHO "←[0;134;" Dir/w "; 13p

@ECHO "←[1;37;44m

(Note: The input method for the "←" character in the batch file is to press ALT 27 on the keyboard in the edit state)

DOS command is the person to contact the computer first to learn, for many people is too familiar too simple, in fact, in these commands contain a wealth of content, still need to be further to understand to develop, if you are a conscientious people will certainly from these self-knowledge of the command found new sparkle, Amoy real gold.

Windows echo Command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.