Basic-batch file Introduction

Source: Internet
Author: User

Files with the extension BAT (or CMD in NT/2000/XP/2003) are batch files.

===== Willsort compilation ======================================== =====
. Bat is a batch processing file under DOS
. CMD is another type of batch file in the NT kernel command line environment.
In a broader sense, Unix shell scripts, as well as other operating systems and even applicationsProgramThe text interpreted and executed by the Shell has a very similar role with the batch processing file, and is also interpreted and executed by the dedicated interpreter in the unit of action, this text form is more commonly referred to as the scripting language. Therefore, to a certain extent, batch, Unix shell, awk, basic, Perl, and other script languages are the same, except that the scope of application and interpretation platforms are different. Even some applications still use batch processing, and their content and extensions are completely different from those of DOS batch processing.
==========================================

First, the batch processing file is a text file. Each line of this file is a DOS command (most of the time it is like the command line we run at the DOS prompt ), you can use any text file editing tool such as edit in DOS or notepad in Windows to create and modify batch files.

===== Willsort question note ============================
Non-DOS commands can be used in batch files, or even common data files that do not have executable features. This is due to the involvement of the new interpretation platform, windows, this makes batch processing applications increasingly "marginalized ". Therefore, the batch processing we discuss should be limited to the DoS or command line environment. Otherwise, many concepts and settings must be relatively large.
======================================

Second, the batch processing file is a simple program that can control the command running process through the conditional statement (IF) and flow control statement (goto, you can also use the for statement to execute a command cyclically in batches. Of course, the programming capability of batch processing files is very limited than that of C language and other programming statements, and it is also very nonstandard. The program statements for batch processing are several DOS commands (including internal commands and external commands). The batch processing capability depends on the commands you use.

===== Willsort compilation ============================
The batch file can also be called the batch program, which is different from the compiled language.C LanguageFor example, a file with the extension of C or CPP can be called a C language file or a C language file.Source codeHowever, only the compiled and connected EXE files can be called C language programs. Because batch files are both readable and executable, the boundaries of these titles are vague.
======================================

Third, each written batch processing file is equivalent to a DoS external command. You can put the directory in your dos search path) so that it can run in any location. A good habit is to create a bat or batch directory (for example, c: \ batch) on the hard disk, and then put all the batch files you have compiled into this directory, in this way, you only need to set C: \ batch in the path, and you can run all your batch processing programs at any location.

==== Willsort compilation ====
In the case of a DOS system, the executable program can be divided into five sub-categories. The execution priorities are: doskey macro commands (pre-resident memory), command. internal commands in COM (in memory at any time according to the memory environment), executable programs with the COM Extension (directly loaded into memory by command.com ), executable programs with exe extensions (loaded into memory after command.com is relocated), and batch processing programs with BAT extensions (analyzed by command.com, according to the content in the order of priority to call the 2, 3, 4, 5 executable programs, analysis of a row, execute a line, the file itself does not load into memory)
================

Fourth, in DOS and Win9x/me systems, C: autoexec under the root directory. bat batch files are automatically run batch files. Each time the system starts, the files are automatically run. You can put the commands to be run every time the system starts, for example, you can set the search path, call the mouse driver and disk cache, and set system environment variables. The following is an example of autoexec. Bat running on Windows 98:
@ Echo off
Path c: \ windows; C: \ WINDOWS \ command; C: \ UCDOS; C: \ dostools;

C: \ systools; C: \ wintools; C: \ batch
LH smartdrv. EXE/x
LH doskey. com/insert
LH ctmouse. exe
Set temp = D: \ Temp
Set TMP = D: \ Temp
==== Willsort compilation ====
Autoexec. bat is the automatic Run batch file of the DOS system, which is interpreted and executed when command. com is started;
In the Win9x environment, dosstart is supported. bat, winstart. BAT and many other batch files that run automatically. bat is also added. DOS. w40. bak. old. PWS and many other variants to adapt to complex environments and changing needs.

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.