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 commandEchocan also output information to the consoleecho off: Closes the command for the output execution.dosecho on: Opens the output execution command to thedosecho hello: OutputhelloTodoscan also output content to a fileecho hello > c:\test.txt: Createtext.txtand writehelloecho world >> c:\test.txt: AppendworldTotest.txtFile 6. Control output@@Represents a command that does not display the current line
@echo off //@后的命令只执行不显示
6.gotoJump commandgoto labelExecute jumplabelIn the format (preceded by a colon in the identifier):label7. Notes:rem
rem 此处内容不会被执行
8. Pause:pauseAfter the General command is executeddosThe window will be closed, plus apauseAfter 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"Call2.batand pass in two parameters 10. Calling an external program:startCall the external program, allDOSBoth command and command-line programs can bestartcommand to call the other later used in the supplement comes in
Common bat Batch Commands