Batch DOS Basic Commands

Batch (Batch), also known as batch script. As the name implies, batch processing is the batch processing of an object. Batch files have the extension bat.

Batch files, or batch programs, are ordinary text files consisting of strips of DOS commands that can be edited directly with Notepad.

Type the name of the batch file in the "Command Prompt", or double-click the batch file, and the system will call Cmd.exe to run the batch program.

In general, each command occupies one line; of course, multiple commands can be separated by specific symbols (such as &, &&, |, ||, etc.) and written into the same line;

 

Common commands

1. echo {on/off} echo

2.rem annotation

3.pause

4.call call another batch program

5.start call external program

6. goto jump command

7.set display set or delete variables

Introduction to Symbols 

1. @    echo shield, do not display the command after @

2. Redirect 1: > with >> 

    Redirect output information to the specified device or file. The system defaults to output to the monitor.
    For example: echo aaaaa>a.txt The information aaaaa displayed on the display can be output to the file a.txt, and there is no display on the screen. If the file a.txt already exists, the command will first erase all the information in a.txt, and then write the information aaaaa; if a.txt does not already exist, the command will create a new a.txt file, and Write information aaaaa.
    echo aaaaa>>a.txt is similar to echo aaaaa>a.txt. The difference is: if a.txt already exists, >a.txt will erase the original content in a.txt, while >>a.txt does not erase the original content, but only adds at the end of the a.txt file Information aaaaa. When a.txt does not exist, there is no difference between the two.
    It should be noted that, because of the particularity of numbers, when echo outputs numbers, please add spaces after them, for example: echo 9313 >a.txt, otherwise the output may be incomplete.
3. Redirect 2: <
Redirects the source of input information to the specified device or file. The system reads input information from the display by default
4. Pipe Symbol |
Redirect the output of the command before the pipe symbol to the command after the pipe symbol as the input of the latter command.
echo y|del /p a.txt --- whether to delete a.txt? Y
5. Escape character ^
Converting a special symbol to a general symbol, that is, stripping the special status of the special symbol. Special symbols refer to: | & > <
 

folder management

cd displays the current directory name or changes the current directory.
md creates a directory.
rd deletes a directory.
dir displays a list of files and subdirectories in a directory.
tree Graphically displays the folder structure of a drive or path.
path Displays or sets a search path for executable files.
copy copies files and directory trees

file management

type displays the content of the text file.
copy Copies one or more files to another location.
del deletes one or more files.
move moves files and renames files and directories. (Not available in Windows XP Home Edition)
ren to rename the file.
replace replaces the file.
attrib Display or change file attributes.
find searches for a string.
fc compares two files or two sets of files and shows the difference between them

network command

ping for network connectivity testing, name resolution
ftp file transfer
net network command set and user management
telnet remote login
ipconfig displays and modifies TCP/IP settings
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326275890&siteId=291194637