Source: China DOS Alliance Joint DOS
Introduction to batch
The extension is a file that BAT (or CMD in NT / 2000 / XP / 2003) is a batch file.
==== Willsort Note =======================================
.bat is the batch file under DOS
.cmd is another batch file for the NT core command line environment
From a broader perspective, UNIX's shell script and other operating systems are interpreted by the case, which has a text of the case.
Similar effects, and also explained by a dedicated interpreter in behavior units, which is more common in the form of a scripting language. So from a certain degree analysis
Script language such as Batch, UNIX Shell, AWK, BASIC, Perl is the same, but the scope of the application is different and the platform of the interpretation is different. Even some
The application is still used in batches, and its contents and extensions are completely different from DOS batch.
====================================
First batch file is a text file, each line of this file is a DOS command (most of us seem to have the command line of the DOS prompt.
Sample), you can create and modify batch files using any text file editing tools such as EDIT or Windows Notepad (NOTEPAD).
==== Willsort inscription ====================
A non-DOS command can be used in the batch file, and even a normal data file without executable characteristics is used, which is the new explanation of the Windows system.
The application of the platform makes the application of the apparatus becomes more and more "marginalized". So the batch we discussed should be limited to the DOS environment or the command line environment, otherwise many ideas
And settings need to be made relatively large changes.
=========================
Second, the batch file is a simple program that can control the process running through the conditional statement (IF) and process control statement (GOTO), can also be in batches
Use a loop statement (for) to loop the execution of a command. Of course, the programming ability of the batch file is very limited and very limited.
Not standardized. The program statement statement is a DOS command (including internal commands and external commands), while the ability to batch depends primarily on the command you are using.
.
==== Willsort Note ================== Batch file can also be called Batch Program, this point and compilation The language is different, in the C language, the extension is C
Or CPP files can be called C language files or C language source code, but only after compiling the EXE file can be called C language programs. Because of the batch file
Itself has both the readability of the text, and has the executability of the program, which is relatively blurred.
===========================
Third, each prepared batch file is equivalent to a DOS external command, you can put it in your DOS search path (PATH) to make it
Can be run in any location. A good habit is to create a BAT or BATCH directory (for example, C: / Batch) on the hard disk, then put all your batch.
The file is placed in this directory, so as long as you set up C: / BATCH in the PATH, you can run all your written batch programs in any position.
==== Willsort Note =====
In terms of pure DOS system, the executable program can be subdivided into five categories. According to the execution priority, it is: doskey macro command (pre-resident memory),
The internal command in Command.com (according to the memory environment is stationed at any time), with COM-extension-enformers (directly loaded directly from Command.com)
, Executable executables with an EXE bit extension (loaded into memory after reconnection), the batch program (interpretation of the Command.com)
Analysis, according to its content, the second, 3, 4, 5 can be executed in priority, analyze one line, execute a line, the file itself does not load memory)
============
Fourth, under the DOS and WIN9X / ME system, the autoexec.bat batch file under the root directory is automatically running batch file, which will automatically run each time the system is started.
This file, you can put the commands you want to run each time you start in this file, such as setting the search path, transfer the mouse driver and disk cache, set the system ring
Square variables, etc. Below 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 the automatic run batch file for the DOS system, interpreted by Command.com.
In the Win9X environment, not only adding many other automatic running batch files such as dosstart.bat, WinStart.bat, but also increases autoexec.bat.
Plus .dos .w40 .bak .old .pws, many variants, including complicated environment and multiple demand.
==== Willsort note =============
The following is the classification of the command, there are many places worth scrutinizing. The @ 本 不 @ @ 常 也 也 也 入 入 入 入 入 入 入 入 入 入 入 入
All commands in the command are common commands. It is recommended to divide the command referenced by the batch into three categories: internal commands, external commands, third-party programs. Internal life
There is a class that is dedicated to or often used in batch commands to be called "batch commands" dedicated to or often used in batch.
The following excerpts the text of the "Batch Command" in the MS-DOS 6.22 help documentation, of course, some concepts and definitions have been behind.
Batch command
Batch file or batch program is a text file containing several MS-DOS commands, the extension is .bat. When the name of the batch handler is knocked in the command prompt
MS-DOS group executes commands in this batch program.
Any commands available under the command prompt can be used in the batch program. In addition, the following MS-DOS command is specifically used in a batch program.
==========
Common command
Echo, @, call, pause, remote: Use :: Replace REM) is the most commonly used commands of the batch file, and we start learning from them.
==== Willsort Note ===========
First, @ is not a command, but a special tag for DOS batch, only for shielding command lines. Below is the DOS command line or batch may see
Some special tags:
Cr (0D) command line end
Escape (1b) ANSI escape character boot
Space (20) common parameter definition
Tab (09); = Uncommon parameter definition
COPY command file connection
*? File wildcard
"" Character string definition
| Command Pipe
<>> file redirector
@ Command line retracting mask
/ Parameter switch guidance
: Batch label guidance
% Batch variable guidance
Second, :: Indeed can play REM's annotation, and more concise; but two points need to pay attention:
First, in addition to ::: Out of the character line, it is considered as a label in the batch, but directly ignores all the following content, just to be with normal standard
The difference is the difference. It is recommended to use the label that Goto's unrecognizable, ie, followed by a special symbol of a non-alphanumeric.
Second, different from the REM is :: The character line will not be elected when executed, whether or not, use the Echo ON to open the command line echo status, because the command interpreter does not think he
It is a valid command line, in this point, REM will be more applicable to :: :: other, REM can be used in config.sys files.
=====================
Echo indicates that the character echo off after this command indicates that all run commands after this statement does not display the command line itself.
@ @ And the echo offline, but it is the most in front of each command line, indicating that the command line does not show this line when running (only the current line).
Call calls another batch file (if you do not use Call to directly call other batch files, then the current file will not be returned after the batch file is executed.
Perform a subsequent command for the current file).
PAUSE runs this sentence to suspend the execution of the apparatus and display the prompts of the press any key to contact ... on the screen, wait for the user to continue after pressing any key
REM indicates that the characters after this command are interpreted (notes), not executed, just give yourself reference (equivalent to comments in the program).
==== Willsort Note =====
The description here is more confusing, it is better to directly reference the command line of the command.
-------------------------
Echo
When the program is run, the body shown or hides the body in the batch program. Can also be used to allow or prohibit the return of the command.
When running a batch program, MS-DOS is generally displayed on the screen (emission) batch program on the screen.
Use the echo command to turn this feature.
grammar
Echo [on | OFF]
To display a command with the echo command, you can use the following syntax:
Echo [Message]
parameter
ON | OFF
Specifies whether the command is allowed to return. To display the current ECHO settings, you can use the Echo without parameters
command.
Message
Specifies the body that allows MS-DOS to display on the screen.
-------------------
Call
Call another batch program from a batch program without causing the initiation of the first batch.
grammar
Call [Drive:] [PATH] FileName [Batch-parameters]
parameter
[Drive:] [PATH] FileName
Specifies the name of the batch program to be called and its storage. The file name must be extension with .bat.
Batch-parameters
Specify the command line information required for the batch program.
-------------------------------
PAUSE
The execution of the suspected batch program and displays a message, prompting the user to continue executing by any key. Can only be batch
This command is used in the procedure.
grammar
PAUSE
REM
Add annotations to batch files or config.sys. You can also use the REM command to block the command (in config.sys)
You can also replace the REM command with a semicolon (;), but it cannot be replaced in the batch file).
grammar
REM [String]
parameter
String
Specifies the command to be masked or the annotations to be included.
=====================================================================================================================================================
Example 1: Edit a.bat file with Edit, enter the following contents After the store is c: /a.bat, you can implement it after executing the batch file: write all files in the root directory to A.txt
In starting UCDOS, enters WPS and other functions.
The content of the batch file is: Command Note:
@echo off does not show the subsequent command line and the current command line
Dir c: /*.*> a.txt writes the C disk file list to A.txt
Call C: /ucdos/ucdos.bat call UCDOS
echo Hello, "Hello"
Pause pause, wait for the button to continue
REM is ready to run WPS Note: Prepare to run WPS
CD UCDOS enters UCDOS directory
WPS runs WPS
Batch file parameters
Batch files can also use parameters like the C language function (equivalent to the command line parameters of the DOS command), which requires a parameter representator "%".
% [1-9] indicates parameters, and parameters refer to a string separated by space (or Tab) after running the batch file. Variables can be represented from% 0 to% 9,% 0
The batch command itself, other parameter strings are represented by% 1 to% 9.
Example 2: C: There is a batch of processing files in the root directory name F.BAT, the content is:
@echo off
Format% 1
If you do C: /> f A:
Then when F.Bat is executed,% 1 represents A:, so FORMAT% 1 is equivalent to format A:, then the above command is actually executed in Format A:
Example 3: C: The next batch of processing files in the root directory name is T.BAT, the content is:
@echo off
TYPE% 1
TYPE% 2
So running c: /> t a.txt b.txt
% 1: Represents A.txt
% 2: Represents B.TXT
The above command will sequentially display the contents of the A.TXT and B.TXT files.
==== Willsort note ===============
The parameter is also treated as a variable in the batch, so the percentage is used as the guide, and thereafter, it is subsequently constituted by a number in 0-9 constitutes a parameter reference. Reference and parameters
The relationship between such as% 1 and A:) is similar to the relationship between variable pointers and variables. When we want to reference the eleventh or more parameters,
The parameter start pointer of DOS must be moved. The shift command is acting as the role of this mobile pointer, which moves the starting pointer of the parameter to the next parameter, similar C
The pointer operation in the language is shown below:
Initial state, cmd is the command name, you can use% 0 reference
CMD arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 ARG10
^ ^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | | | | |
% 0% 1% 2% 3% 4% 5% 6% 7% 8% 9
After 1 SHIFT, the CMD will not be referenced.
CMD arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 ARG10
^ ^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | | | | |
% 0% 1% 2% 3% 4% 5% 6% 7% 8% 9
After 2 SHIFT, Arg1 was also discarded,% 9 points to empty, no reference significance
CMD arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 ARG10
^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | | | | |
% 0% 1% 2% 3% 4% 5% 6% 7% 8
Unfortunately, Win9X and DOS do not support Shift's inverse operation. Only in the NT core command line environment, Shift supports / n parameters, you can
The number is a reference to return to the mobile start pointer.
====================
Special command
If Goto Choice for is a relatively advanced command in a batch file. If you are very skilled, you are an expert in batch files.
First, if the IF is a conditional statement, it is used to determine whether it meets the specified conditions, thereby deciding to perform different commands. There are three formats:
1, if [not] "parameter" == "string" command to be executed
If the parameter is equal to (NOT means not et al, the following) The specified string, the condition is established, run the command, otherwise run the next sentence.
Example: if "% 1" == "a" format A:
==== Willsort Note
The description of this point is:
IF [not] string1 == String2 Command
There is a matter of this point here:
1. The double quotes containing the string are not necessary, but only a "air defense" character used in habits.
2. String1 is not necessarily parameters, which can also be environment variables, cyclic variables, and other string constants or variables.
3. Command is not a syntax, String2 follows a space to form a valid command line
==============================
2, if [not] exist [path /] file name to be executed
If you have a specified file, the condition is true, run the command, otherwise run the next sentence.
Such as: if exist c: /config.sys type c: /config.sys
Indicates that it is displayed if there is a C: /Config.sys file.
****** WILLSORT Note ********
You can also use the following usage:
IF EXIST COMMAND
Device refers to a device that has been loaded in the DOS system, usually: in Win98:
AUX, PRN, CON, NUL
COM1, COM2, COM3, COM4
LPT1, LPT2, LPT3, LPT4
XMSXXXX0, EMMXXXX0
A: B: C: ...,
Clock $, Config $, DBLBUFF $, IFS $ HLP $
The specific content will be slightly different due to the hard software environment. When using these device names, the following three points are required:
1. The device does exist (except for software virtual devices)
2. The device driver has loaded (AUX, PRN and other standard devices are defined by the system default)
3. The device is ready (mainly refers to A: B: ..., COM1 ..., LPT1 ..., etc.)
You can review the equipment loaded in your system by command MEM / D | Find "Device" / i.
In addition, in the DOS system, the device is also considered a special file, and the file can also be referred to as a character device;
Because the device (Device) and the file are managed using the handle (Handle), the handle is the name, similar to the file name, but the handle is not applied to disk management.
Instead of being used in memory management, the so-called device loading is also referred to in the memory to assign a referenced handle for it.
==================================
3, if Errorlevel
Many DOS programs return a numeric value after running, it is used to indicate the result of the program run (or status), and can determine the program's return through the if ErrorLevel command.
Return value, decide to perform different commands according to different return values (the return value must be arranged in order from large to small). If the return value is equal to the specified number, the condition is established, run the command, otherwise run the next sentence.
If Errorlevel 2 Goto X2
==== Willsort Note ===========
The return value is not necessary from the order of large to small, but only the habitual usage when the command is goto. When using the set as an execution command, it is usually from small to
In large order, please use the following sequence form: you need to put the return code into the environment variable.
IF Errorlevel 1 Set EL = 1
IF ErrorLevel 2 Set EL = 2
IF Errorlevel 3 Set EL = 3
IF Errorlevel 4 set el = 4
IF Errorlevel 5 Set EL = 5
...
Of course, you can also use the following loops to replace, the principle is consistent:
For %% E in (1 2 3 4 5 6 7 8 ...) DO if ErrorLevel %% E SET EL = %% E
More efficient and simple usage, you can refer to another article on get Errorlevel
This behavior is that if Errorlevel compares the judgment condition of the return code is not equal to, but is greater than or equal. Due to GOT's jump characteristics, it is small to large.
Sort can result in jump out of the smaller return code; and due to the "repetitive" assignment characteristics of the set command, the smaller return code "coverage" is larger.
Return code.
In addition, although if ErrorLevel =
The characters are ignored
===========================
Second, the GOTO batch file is running here will jump to the reference numeral specified by Goto (the label is used by the label, the label is used to define the standard string), and the goto statement is generally
If the IF is used, different command groups are performed according to different conditions.
Such as:
Goto end
: END: END
echo this is the end
The label is defined with the ": string", and the routing is not executed.
==== Willsort Note
Label is often translated into "label", but this does not have extensive convention.
GOTO and: The combination of jumps can be implemented in the middle of the way, and the combination of IF can implement the conditional branch of the execution process, multiple IF can implement the command group, similar C
Switch Case structure or SELECT CASE structure in Basic, a large-scale and structured command packet enables function functions in advanced languages. Here is
Batch and C / Basic Control of grammatical structure:
Batch C / Basic
Goto &: Goto &:
GOTO & IF IF {} & else {} / if & elseif & Endif
Goto &: & If ... Switch & Case / Select Case
Goto & IF & Set & Envar ... function () / function (), SUB ()
===================================3, Choice uses this command to allow users to enter a character (for choosing ), Thereby returning different Errorlevel according to the user's selection, and then at IF
Errorlevel works, runs different commands according to the user's selection.
Note: The choice command is the external command provided by the DOS or Windows system. Different versions of the Choice command speech will be slightly different. Please use the khoice /? View.
Choice's command syntax (this syntax is the syntax of the choice command in Windows 2003, and the other version of the Choice command syntax is similar to this.):
Choice [/ cchoices] [/ n] [/ cs] [/ t timeout / d choice] [/ m text]
description:
This tool allows users to select an item from the selection list and return the index of the selected item.
parameter list:
/ C Choices Specifies the list of options to create. The default list is "YN".
/ N hides the list of options in the prompt. Tip the previous message get displayed,
The option is still in an enabled state.
/ Cs allows selection options to select. This tool is by default
Is not case-sensitive.
/ T timeout makes the number of seconds before the default selection. Acceptable values are from 0
To 9999. If 0 is specified, there will be no pause, the default option
Will get the choice.
/ D Choice Specifies the default option after NNNN seconds. Character must be selected with / c
A set of options specified in the item; at the same time, NNNN must be specified with / t.
/ M text Specifies the message to display before prompt. If not specified, the tool is only
Show prompts.
/? Display help messages.
note:
The ErrorLevel environment variable is set to the key index selected from the selection set. The first choice listed
Alternative to 1, the second selection returns 2, and so on. If the user presses the key is not a valid choice,
This tool will make a warning sound. If the tool detects an error status, it will return 255
Errorlevel value. If the user presses Ctrl Break or CTRL C key, the tool will return 0
ERRORLEVEL value. When using an Errorlevel parameter in a batch, the parameters drop
Order.
Example:
CHOICE /?
Choice / C YNC / M "Confirm, press Y, no Please press N, or cancel, press C."
CHOICE / T 10 / C YNC / CS / D Y
Choice / C AB / M option 1 Select a, option 2 Please select B. "
Choice / c ab / n / m "option 1 Select a, option 2 Please select B."
==== Willsort Note ===============================
I list the use of Choice under Win98, and I have been distinguished.
Waits for the user to choise one of a set of choices.
Waiting for the user to choose a group of choice [/ c [:] choices] [/ n] [/ s] [/ t [:] c, nn] [text]
/ C [:] Choices Specifies Allowable Keys. Default is Yn
Specify the allowed button (to be selected by the characters), default is YN
/ N do not display choices and? At end of prompt string.
Do not display the question mark and the selected character in the prompt string
/ S Treat Choice Keys as Case Sensitive.
Sensitive when handling the characters
/ T [:] C, NN Default Choice to C after nn seconds
Default selection in nn seconds
Text Prompt String to Display
Tip string to display
Errorlevel IS set to offset of key user presses in choices.
Errorlevel is set to the user typed by the user in the offset value in the selected character.
=====================================
If I run the command: choice / c ync / m "Confirm, press Y, no, please press N, or cancel, press C."
The screen will be displayed:
Confirm, press Y, no, press N, or cancel, press C. [Y, n, c]?
Example: Test.bat is as follows (note that when the return value is used to determine the return value with if ErrorLevel, press the return value from high to low alignment):
@echo off
Choice / C DME / M "DEFRAG, MEM, END"
IF Errorlevel 3 Goto end
IF Errorlevel 2 Goto Mem
IF Errorlevel 1 Goto Defrag
: defrag
C: / DOS / DEFRAG
Goto end
: MEM
MEM
Goto end
: END: END
Echo good bye
After this batch is run, "DEFRAG, MEM, END [D, E]?" Will be displayed, and the user can select D M E, and then the IF statement determines based on the user's selection.
The block of the label is DEFRAG, m represents a block that executes the label MEM, e means executing the block of the label as an end, and each block is finally taken by Goto End.
Skip at the END Number, then the program will display good bye, the batch run ends.
Fourth, for loop command, as long as the condition is in line with, it will execute the same command multiple times.
grammar:
Perform a particular command to each file in a set of files.
For %% Variable In (SET) Do Command [Command-Parameters]
%% variable specifies a single letter replaceable parameter.
(SET) Specify one or a set of files. You can use wildcards.
Command specifies the command to execute each file.
Command-parameters
Specify a parameter or command line switch for a specific command.
For example, there is a line in a batch file:
For %% c in (* .bat * .txt) Do Type %% C
The command line displays all the contents of the files with BAT and TXT-based files in the current directory.
==== WILLSORT bet ============================================== ========== Need to indicate that when the string in () is not single or multiple file names, it will be simply replaced by a string, and this characteristic plus () can Embed multiple words
The characteristics of string are obvious that FOR can be viewed as a traversal cycle.
Of course, in the NT / 2000 / XP / 2003 series of command line environments, the for is given more features that can analyze the command output or the string in the file.
There are many switches being used to extend the file replacement.
============================================================================================================================================================================================================= ======================
Batch example
IF-EXIST
1) First use Notepad in C: / create a TEST1.BAT batch file, the file content is as follows:
@echo off
If exist /autoexec.bat type /autoexec.bat
If not exist /autoexec.bat echo /autoexec.bat does not exist
Then run it:
C: /> Test1.bat
If C: / exists autoeexec.bat file, then its content will be displayed, if there is no existence, the batch will prompt you if the file does not exist.
2) Then establish a Test2.bat file, as follows:
@Echo off
IF EXIST /% 1 TYPE /% 1
IF not exist /% 1 ECHO /% 1 does not exist
carried out:
C: /> Test2 AutoExec.bat
This command runs the result.
Description:
(1) If exist is used to test whether the file is existing, the format is
IF exist [Path File Name] command
(2)% 1 in the test2.bat file is the parameter, DOS allows 9 batches of parameter information to batch file,% 1 ~% 9 (% 0 means the Test2 command itself), this is a bit
The relationship between the real parameters and meticulum parameters in the programming,% 1 is the ginseng, and Autoexec.Bat is inform.
==== WILLSORT bet ============================================== ========== DOS does not "Allow 9 Batch Parameter Information" limit, the number of parameters will only be limited by the command line length and the modified command processing capability. However, we are in batches
In the handler, 10 parameters can only be referenced at the same time, because DOS only gives 10% of the ten parameter references.
============================================================================================================================================================================================================= ======================
3) Further, create a file called Test3.bat, the content is as follows:
@echo off
IF "% 1" == "a" echo xiao
IF "% 2" == "b" echo tian
IF "% 3" == "c" echo xin
If you run:
C: /> TEST3 A b C
The screen will be displayed:
Xiao
Tian
Xin
If you run:
C: /> TEST3 A B
Display on the screen
Xiao
Tian
During this command execution, DOS specifies an empty string to the parameter% 3.
2, if-errorlevel
Establish TEST4.BAT, the content is as follows:
@Echo off
Xcopy C: /autoexec.bat D: /
IF Errorlevel 1 Echo file copy failed
IF Errorlevel 0 Echo success copy file
Then execute the file:
C: /> TEST4
If the file copy is successful, the screen will display "Successful Copy File", otherwise "file copy failed" will be displayed.
If ErrorLevel is used to test the return value of the previous DOS command, pay attention to the return value of the last command, and the return value must be in accordance with the large to small order
The order is judged.
So the batch file below is wrong:
@Echo off
Xcopy C: /autoexec.bat D: /
IF Errorlevel 0 Echo success copy file
IF Errorlevel 1 Echo Did not find a copy file
If Errorlevel 2 Echo users suspended copy operation via Ctrl-C
IF Errorlevel 3 Echo Preset Error Block File Copy Operation
IF Errorlevel 4 Echo copy process during writing
Whether the copy is successful, followed by:
Did not find a copy file user via Ctrl-C to abort copy operation
Preset error Block file copy operation
Write disk error during copying
Will be displayed.
The following is the return value of several common commands and their representatives:
BACKUP
0 backup success
1 Did you find a backup file
2 File shared conflict blocks backup completion
3 users use Ctrl-C to stop backup
4 Make backup operations to abort the backup operation due to fatal errors
Diskcomp
0 disk is more
1 disk comparison
2 users suspend comparison operation via Ctrl-C
3 Since the fatal error makes the comparison operation
4 Preset error abort
Diskcopy
0 disks copy operation
1 non-pendant read / write wrong
2 Users end copy operation via Ctrl-C
3 Copy stop due to fatal processing errors
4 Preset error block copy operation
Format
0 Successfully
3 users suspend formatted processing via CTRL-C
4 Surperse formatting due to fatal processing errors
5 Type N of N under the prompt "Proceed with format (y / n)?"
xcopy
0 Success copy file
1 Did you find a copy file
2 users suspend copy operation via CTRL-C
4 Preset error Block file copy operation
5 write disk errors during copying
==== WILLSORT bet ============================================== ==========
Chkdsk
0 did not find an error
255 find one or more errors
Choice
0 Users Press CTRL C / BREAK
1 user presses the first button
255 Detecting the error condition in the command line
Other users pressed the valid characters in the list
DEFRAG
0 Debris compression is successful
1 Internal error
2 There is no empty cluster on disk. To run the defrag, there must be at least an empty cluster
3 Users with Ctrl C exit DEFRAG
4 general error
5 DEFRAG encounters errors when reading
6 DEFRAG encounters errors when writing
7 Distribution space is wrong
8 memory error
9 does not have enough space to compress disk fragmentation
Deltree
0 Successfully remove a directory
Diskcomp
0 two discs
1 find different
2 Press Ctrl C to terminate comparison
3 serious errors
4 initialization error
Find
0 Find success and at least find a matching string
1 Find success but did not find a matching string
2 There is an error in the lookup
Keyb
0 Keyboard definition file load success
1 use illegal keyboard code, character set or syntax
2 Keyboard definition files or not found
4 keyboard, mistaker communication
5 required character sets are not ready
Move
0 Successfully moved the specified file
1 has a mistake
MSAV / N
86 checks the virus
Replace
0 Replace successfully replaced or joined files
1 MS-DOS version and Replace is not compatible
2 Replace can't find the source file
3 Replace does not find the source path or target path
5 Cannot access files to be replaced
8 memory is not enough to implement Replace
11 command line sentence error
RESTORE
0 Restore successfully restores the file
1 Restore can't find a file to be recovered
3 Users Press CTRL C to Terminate Recovery Process
4 Restore terminates due to errors
Scandisk
0 Scandisk did not detect any errors on the drive it checked
1 Due to the syntax of the command line, it is not possible to run Scandisk.
2 ScanDisk unexpectedly terminated due to internal errors due to internal errors
3 Users let ScanDisk exit 4 When discharging, the user decides to exit in advance
254 ScanDisk finds disk failure and has all corrected
255 ScanDisk finds disk failure, but failed to correct
setVer
0 SETVER successfully completed the task
1 Users specify an invalid command switch
2 Users specify an illegal file name
3 Do not have enough system memory to run commands
4 Users specify an illegal version number format
5 SETVER Didn't find the specified item in the version table
6 SETVER Didn't find a setver.exe file
7 Users specify an illegal drive
8 users specify too much command line parameters
9 SetVer detected lost command line parameters
10 When reading the setver.exe file, the setver detects an error.
11 setver.exe file corruption
12 Specified setver.exe files do not support version table
13 There is no sufficient spatial storage in the table.
14 Setver detects an error when writing the setver.exe file
============================================================================================================================================================================================================= ======================
3, if string1 == String2
Establish TEST5.BAT, the file content is as follows:
@echo off
IF "% 1" == "a" Format A:
carried out:
C: /> TEST5 A
Whether the A: disc is formatted on the screen.
Note: In order to prevent the parameters from being empty, the string will generally use double quotes (or other symbols, notice that the reserved symbol) is enclosed.
Such as: IF [% 1] == [a] or if% 1 * == a *
5, goto
Establishing Test6.bat, the document content is as follows:
@Echo off
IF exist c: /autoexec.bat goto _copy
Goto _done
: _COPY
Copy C: /autoexec.bat D: /
: _DONE
note:
(1) Before the label is the colon of the ASCII character ":", there is no space between the colon and the label.
(2) Name rules of the label are the same as the name rules of the file name.
(3) DOS supports the label of the longest eight characters. When it is not possible to distinguish two labels, it will jump to the nearest label.
==== WILLSORT bet ============================================== ==========
1) Number is also called label (label)
2) The tag cannot start with most non-alphabetic characters, and a lot of file names can be used 3) When the two labels cannot distinguish, the top of the label will be jumped to the position.
============================================================================================================================================================================================================= ======================
6, for
Establish C: / Test7.bat, the document content is as follows:
@Echo off
For %% c in (* .bat * .txt * .sys) do type %% C
run:
C: /> TEST7
After execution, all the C: Panhe TXT, SYS is displayed in BAT, TXT, and SYS (excluding the hidden file).