Common dos commands frequently used in applications of DOS batch processing files

Source: Internet
Author: User

Echo, @, call, pause, and rem are the most common commands for batch file processing. We started from them. Echo indicates the characters after this command
Echo off indicates that after this statement, all running commands do not display the command line itself.
@ Is similar to echo off, but it is added at the top of other command lines, indicating that the command line itself is not displayed during running.
Call calls another batch file (if another batch file is called directly, subsequent commands of the current file cannot be executed after that file is executed)
Running pause will be paused, and Press any key to continue...
Rem indicates that the character after this command is interpreted as a line. If it is not executed, it will only be used for future search.

For example, use edit to edit. bat file, enter the following content and save the disk as c: \. bat, after executing the batch processing file, you can: write all the files in the root directory into a.txt, start UCDOS, enter WPS and other functions.

The content of the batch file is: file representation:

Echo off command line not displayed

Dir c: \ *. *> a.txt: Write the c-drive file into a.txt.

Call c: \ ucdos. bat call ucdos

Echo Hello show "hello"

Pause and wait for the button to continue

Rem uses wps annotation to use wps

Cd ucdos enters the ucdos directory

Wps use wps

You can also use parameters in a batch file like the C language, which requires only one parameter identifier %.

% Indicates a parameter. A parameter is a string added after the file name when a batch file is run. Variables can be represented from % 0 to % 9, % 0 indicates the file name itself, and strings are represented in the order of % 1 to % 9.

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

If C: \> f a: is executed, format:

Another example is C: The name t. bat of the batch of files processed in the root directory, and the content is type % 1 type % 2.

Run C: \> t a.txt B .txt to display the contents of a.txt and B .txt in sequence.

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.