Common DOS commands often used to apply DOS batch files


Echo, @, call, pause and rem are the most commonly used commands for batch files. We’ll start from them. Echo , indicates the character after the command is displayed
Echo off means that all commands running after this statement do not display the command line itself
@It is similar to echo off, but it is added at the front of other command lines, indicating that the command line itself is not displayed at runtime.   
Call ・ call another batch file (if you call another batch file directly, the subsequent commands of the current file cannot be executed after the file is executed)
Pause , running this sentence will pause and display press , any , key , to , continue Wait for the user to press any key before continuing
REM , indicates that the character after this command is an interpretation line, which is not executed, but only for future search

For example, edit a.bat file with edit, input the following contents and save it to C: \ a.bat. After executing the batch file, it can be realized: write all files in the root directory into a.txt, start UCDOS, enter WPS and other functions.  

The contents of the batch file are: file representation:

Echo off does not display the command line

    dir c:\*.* > a.txt write the C disk file list to a.txt

    call c:\ucdos\ucdos. Bat calls UCDOS

Echo # Hello # displays “hello”

Pause pause, wait for the key to continue

REM # use WPS # annotation will use WPS

CD # UCDOS enter UCDOS directory

WPS # use WPS

You can also use parameters in batch files like C language, which requires only one parameter indicator%.  

% refers to the parameter, which refers to the string added after the file name when running the batch file. Variables can range from% 0 to% 9,% 0 represents the file name itself, and strings are represented in the order of% 1 to% 9.  

For example, C: the name of the batch file under the root directory is f.bat, and the content is format% 1

If C: \ > F # A: is executed, format # A:

Another example is C: the name of the batch file under the root directory is t.bat, and the content is “type% 1” and “type% 2”

Then running C: \ > t a.txt b.txt will display the contents of a.txt and b.txt files in sequence