Common bat batch Commands record common batch commands 1. Header settings:
...//例如 title = 批处理测试
2. Color settings
color //例如 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 |
function |
| %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:
2."A""B"//调用2.bat 并传入参数 A , B//使用传入的参数echo %1 //打印第一个参数echo %2 //打印第二个参数echo %0 //打印本身的名称
5. Output command
Echocan also output information to the console
echo off: Closes the command for the output execution.
dos
echo on: Opens the output execution command to the
dos
echo hello: Output
helloTo
doscan also output content to a file
echo hello > c:\test.txt: Create
text.txtand write
hello
echo world >> c:\test.txt: Append
worldTo
test.txtFile 6. Control output
@
@Represents a command that does not display the current line
@echo off //@后的命令只执行不显示
6.
gotoJump command
goto labelExecute jump
labelIn the format (preceded by a colon in the identifier)
:label7. Notes:
rem
rem 此处内容不会被执行
8. Pause:
pauseAfter the General command is executed
dosThe window will be closed, plus a
pauseAfter that, you will stop clicking on any key to exit the interface for easy viewing of execution Results 9. Call Other Batches:
callFor example:
call 2.bat "hello" "world"Call
2.batand pass in two parameters 10. Calling an external program:
startCall the external program, all
DOSBoth command and command-line programs can be
startcommand to call the other later used in the supplement comes in
Common bat Batch Commands