Using ECHO for outputting

The ECHO command can be used to output status messages during the execution of a batch file:

ECHO Hello world...

When executing commands in a batch file, then the command-line for the command is shown unless one specifies the following command at the top of the batch file (Note the "@" keeps the comand from being shown):

@echo off
ECHO Hello world...

To create a newline or carriage return (Notice the "."):

ECHO.

To create a beep sound in the PC-Speaker using CTRL+G (Or ASCII 7 produced by holding down ALT-key and 7-key):

ECHO ^G

To send a keystroke to a program:

ECHO Y | DEL *.*

To create a new file(status.txt) containing a text line:

ECHO No errors detected > status.txt

To append a text line to an existing file(status.txt):

ECHO Batch Program Ends >> status.txt

To create a batch file inside a batch-file:

ECHO ECHO Hello > Hello.bat
CALL Hello.bat

To send a command to a modem connected to the COMx port:

REM *** AT = Attention, M1 = Turn speaker on, L3 = High speaker volume
REM *** X0 = Do not wait for dialtone, DT12345 = Dial 12345
ECHO ATM1L3X0DT12345 > COMx

REM *** AT = Attention, H0 = Hook off the modem
ECHO ATH0 > COMx

More Info MS KB84279
More Info MS KB105940

Updated: 20 October 2008

Tags:
Category:

Leave a Reply

Your email address will not be published. Required fields are marked *