Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write batch processing

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to write batch processing, the article is very detailed, has a certain reference value, interested friends must read it!

Introduction to batch processing

A file with a bat extension (or cmd under nt/2000/xp/2003) is a batch file.

= willsort Note = =

.bat is a batch file under dos

.cmd is another batch file for the nt kernel command line environment

In a broader sense, unix's shell scripts and text interpreted and executed by shells in other operating systems and even applications have a very similar effect to batch files, and are also interpreted and executed by dedicated interpreters in units of behavior. This text form is more commonly referred to as scripting languages. So to some extent, batch, unix shell, 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, but its content and extension are completely different from dos's batch processing.

=

First of all, the batch file is a text file, each line of this file is a DOS command (most of the time we execute the command line at the DOS prompt), you can use Edit under DOS or Windows notepad (notepad) and any text file editing tools to create and modify batch files.

= = willsort caption = =

Non-dos commands can be used in batch files, and even ordinary data files without executable characteristics can be used. Due to the involvement of windows system, a new interpretation platform, the application of batch processing is becoming more and more "marginalized". So the batch we are talking about should be limited to the dos environment or the command line environment, otherwise many concepts and settings need to be changed significantly.

=

Secondly, a batch file is a simple program, which can control the flow of commands through conditional statements (if) and process control statements (goto), and loop statements (for) can also be used in batch processing to loop a command. Of course, the programming ability of batch files is very limited and irregular compared with C language and other programming statements. The program statements of batch processing are DOS commands (including internal and external commands), and the ability of batch processing mainly depends on the commands you use.

= willsort Note = =

Batch files (batch file) can also be called batch programs (batch program), which is different from compiled languages. As far as c language is concerned, files with the extension c or cpp can be called c language files or c language source code, but only compiled linked exe files can be called c language programs. Because the batch file itself has both the readability of the text and the executability of the program, the boundaries of these terms are relatively vague.

=

Third, each written batch file is equivalent to an external command of DOS, and you can put its directory in your DOS search path (path) so that it can run anywhere. A good practice is to create a bat or batch directory on your hard drive (for example, C:\ BATCH), and then put all the batch files you write into that directory, so that as long as c:\ batch is set in path, you can run all the batch programs you write anywhere.

= willsort Note = =

For pure dos systems, executable programs can be subdivided into five categories, arranged from high to low according to execution priority: DOSKEY macro commands (pre-resident memory), internal commands in COMMAND.COM (entering memory at any time according to the environment of memory), executable programs with com extension (loaded directly into memory by command.com), executable programs with exe bit extension (relocated by command.com and loaded into memory) A batch program with a bat bit extension (interpreted and analyzed by command.com, calling 5 executable programs in priority order according to its contents, analyzing one line, executing one line, and the file itself is not loaded into memory)

=

Fourth, in DOS and Win9x/Me systems, C: disk root directory of the AUTOEXEC.BAT batch file is automatically run batch file, each system startup will automatically run the file, you can run the system every time you start the command to run into the file, such as setting the search path, call the mouse driver and disk cache, set system environment variables, and so on. The following is an example of autoexec.bat running under 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 Note = =

AUTOEXEC.BAT is an autorun batch file of the DOS system, which is interpreted and executed by COMMAND.COM at startup

In the Win9x environment, it not only supports DOSSTART.BAT, WINSTART.BAT and many other automatic batch files, but also adds many variants such as .DOS .W40.BAK .OLD. PWS to adapt to the complex environment and changing requirements.

=

The above is all the contents of this article "how to write batches". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report