Common Bat Batch Commands
record common batch commands
1. Title Settings:
title = ...
For example title = batch-processing test
2. Color Settings
Color background color code font colour code
//For example color 47
| Color |
Code |
| Black |
0 |
| Blue |
1 |
| Green |
2 |
| Lake Blue |
3 |
| Red |
4 |
| Purple |
5 |
| Yellow |
6 |
| White |
7 |
| Grey |
8 |
| Light Blue |
9 |
| Light Green |
A |
| Shallow Green |
B |
| Light Red |
C |
| Light Purple |
D |
| Light Yellow |
E |
| Bright White |
F |
3. Parameters:
| command |
role |
| %SystemRoot% |
C:\WINDOWS (%windir% same) |
| %ProgramFiles% |
C:\Program Files |
| %USERPROFILE% |
C:\Documents and Settings\Administrator |
| %appdata% |
C:\Documents and settings\administrator\application Data |
| %temp% |
c:\docume~1\admini~1\locals~1\temp (%tem% same) |
| %appdata% |
C:\Documents and settings\administrator\application Data |
| %os% |
windows_nt (System) |
| %Path% |
%systemroot%\system32 |
| %homedrive% |
C: (System disk) |
| %homepath% |
\documents and Settings\Administrator |
4. Call the batch file and pass the description
For example:
Call 2.bat "a" "B"
//Invoke 2.bat and pass in Parameter A, B
//Use the passed parameter
echo%1 //print the first parameter
echo%2 //print the second parameter
Echo %0 //name of the print itself
5. Output command echo
can also output information to the console
echo off: dos of the command to turn off output execution
echo on: Open output execution command to Dos
echo Hello: output hello to Dos
can also output content to a file
echo Hello > C:\test.txt: Create text.txt and write Hello
Echo World >> c:\test.txt: Append world to Test.txt file
6. Control output @
@ indicates a command that does not display the current line
commands that @echo off//@ only do not display
6.goto Jump Command
Goto label to perform a jump
the label is in the format (preceded by a colon): Label
7. Note: REM
REM content will not be executed here
8. Suspend: Pause
after the General Command executes, the DOS window will close, and after adding pause, it will stop at the interface of pressing any key to easily view the results of the execution.
9. Calling other batches: Call
For example: Call 2.bat "Hello" "world" calls 2.bat and passes in two parameters
10. Calling external program: Start
calling an external program, all DOS commands and command-line programs can be called by the start command
The rest is used in addition.