Recently looked at the cmd command, found that some use it is very convenient. So decided to put these DOS commands sorted out, easy to write. bat batch file.
1 to see first. What is Cmd,.bat:
. BAT is a DOS batch file;
. cmd is another batch file for NT kernel command line environments;
Therefore, there is no essential difference between the two. In a more general sense, Unix shell scripts and other operating systems and even the text that is interpreted by the shell in the application have a very similar effect to the batch file, and the same is done by the dedicated interpreter in the behavior unit, which is more commonly called the scripting language.
So from a degree of analysis, Batch,unixshell,awk,basic,perl and other scripting languages are the same, but the scope of application and interpretation of the platform are different. Even some applications still use the term batch, and their content and extension are completely different from the DOS batch.
The next step is to vfhky the DOS command. The first part is more commonly used, the second part is not much. With these basic DOS commands, it's not hard to write a simple. bat batch file (see the next article for an intranet IP switch with a. bat batch file).
2 The first part: Commonly used DOS commands
@, the screen does not display the current line DOS command
echo off, the screen does not display all the command lines in the bat file
Dir d:*.* >filelist.txt, writes the D-disk file list to Filelist.txt
CLS, clears the contents of the monitor screen so that the DOS prompt is in the upper-left corner of the screen
Color, setting the console foreground and background colors. Can be used under the cmd "color/?" Inquire
Title, set the caption for the console window. Default to "CMD"
CD, abbreviation for change directory in English (toggle directory). such as CD d:sybase, enter Sybase directory
MD, abbreviation for make directory in English (create directory.) For example, MD c:123
Rd, abbreviated (delete directory) of the English remove directory. such as Rd c:123
del, English delete abbreviation (delete). Used to delete one or a group of files in a specified disk, directory, such as Del D:gvim.exe
ren, abbreviation for English rename (renamed). Used to change the name of a file or set of files in a specified disk, directory, [format] ren [c:][path]filename1[.ext] filename2[.ext]
Time to display and set the DOS system times. [Format] time [hh[:mm[:ss[.cc]]]
Date to display and set the DOS system dates. [format] date [MM-DD-YY]
%, a parameter (a string that is added after the file name when the batch file is run, such as% 1,%2, and so on);
%var%, variable var;
, which is used in conjunction with Echo to form "echo.", which acts as a newline;
Call, which invokes another batch program from one batch program without terminating the parent batch program. For example: Call D:b.bat;
: Goto label, Jump to ": Label" label;
REM, the annotation command, corresponds to the "::" command;
Pause, suspend command. At run time, the following text is displayed:
Press any key to continue ... (or: Press any key to continue ...)
Pause > Nul function is the same, the difference is not shown "please press any key to continue ..."
Set to display, set, or delete variables. There are three basic formats: set/a expressions, set [variable=[string]];set/p variable=[promptstring] (the promptstring to the right of the = number is the prompt, not the value of the variable).
Type, text output command;
3 Part Two: Relatively few DOS commands
Start, calling the external program. For example, start "" D:gvim.exe "
format, the disk Formatting command. Format [C:] [Path]format drive:[/s]
Discopy, a disk copy that duplicates a disk that is identical to the original disk content. [format] diskcopy drive name of Source drive
deltree, deletes the directory tree (the entire specified directory tree is eliminated, regardless of whether it is read-only, hidden or not.) )。 Format [C:] [Path] deltree [C1:][path1] [[C2:][path2] [...]]
MEM, an abbreviation of English memory, used to view the size of the computer's memory and the usage of memory. [format] Type the MEM command directly
Chkdsk, an abbreviated English check disk, used to check the usage of your disk. [format] CHKDSK disk name
Find, Search command. Used to search for a specific string in a file. For example:
Type A.txt | Find "Huangke blog" && echo "spicy horizon."
This command will search for "Huangke blog" in A.txt, if the content exists, it will output "spicy horizon."
>, >>
Both are output redirection commands, which are to write the stream text redirection of the preceding command to a file. The only difference is that the,> command writes the new content to the original file after it clears the contents of the original file, and the >> command appends the new content to the original file in a separate line.
<, >&, <&: Three pipe commands (not used)
Enter the redirection command. That is, read the command input from the file instead of reading it from the keyboard.
>&, writes the output of one handle to the input of another handle.
<&, just as opposed to >&, reads input from one handle and writes it to another handle output.
And, combine the connection commands. That is, it can connect n dos commands and then execute them sequentially, ignoring the command that failed to execute.
&&, combine connection commands. It can be combined before and after two commands to be used as a command. Unlike the & command, however,,&& detects that a command has been executed and does not continue to execute the remaining commands once an error is found.
| The function is to make the output of the previous command the input of the last command.
|| , the usage is almost the same as &&, but the opposite is true: when you encounter a command that executes correctly, quit this combination of commands and do not continue with the following command.
At, lists the scheduled commands or scheduled commands and programs that run on the computer at the specified time and date, such as at 12:00 "D:abc.bat".