Batch entry

First, understand what is batch

Batch processing is an object of the batch. Extended batch file called bat, DOS batch is a DOS-based command, used to automatically execute DOS batch command script to achieve a specific operation.

According to my understanding the nature of the batch, is a collection of a bunch of DOS commands in a certain order in which they formed.
So, if you want to write a batch, knowledge of DOS commands is indispensable 

Then, look at a batch of common statement

Echo  command]  

  Open or close the display function echo request back, or displaying a message. If no parameters, echo  displays the current echo setting.  

Rem  Syntax

  Notes command, similar to the C language / * -------- * / , and it will not be executed, just a comment from the role to facilitate others to read  

Pause  command]

Pause command.

Call  Syntax

  Call another batch program from a batch program, and not stopping the parent batch program. call  command accepts as a call target  

  label. If used outside a script or batch file  Call , it will not work on the command line.  

Start  Syntax

  Call an external program, all DOS commands and command-line programs can be a start to invoke a command.

Goto  command]

  Jump command. Program pointer jumps to the specified label, program execution continues from the first batch command tag.  

Set  Syntax

  Display, set or remove variables.

[Echo shield  ]

He said they did not show @ the back of the command

[Redirect 1> and >>  ]

  The output is redirected to a specified device or file. Default output to a display.

Redirect [ 2 <  ]

  Redirect the input source of information for the specified device or file. The system reads the input information from the default display.

 Redirection Example of use:

  =========================================

  @echo off

  ABCDEFG echo - This is a file a.txt information > a.txt

  echo  Please enter any character to enter the end:

  set /p ifo=

  cls

  echo  [Enter the information obtained from the screen]

  echo %ifo%

  set /p ifo=<a.txt

  echo  [from file a.txt input information obtained]

  echo %ifo%

  pause> null

  =========================================

[Pipe symbol  ]

  The front pipe symbol output command to redirect the output to a subsequent pipe symbol commands go back as an input command. Use the format: command_1 | command_2

[Escape character  ]

  Usually a special symbol into the symbol, i.e. a special status peeling special symbols. Special characters refer to: | &> <

Logic operator commands]

   Command logical operators include: & , && , ||

  & - performed unconditionally & behind the command symbol;

  && - When && when the previous command is successful, the implementation && behind the command, or do not perform;

  || - When || when the previous command fails, execute || behind the command, otherwise not executed.

----------- These are some common  bat  commands and logic symbol -----------

 

For DOS commands, you can go online to find their own appropriate

 

If you do not know its use, directly in DOS , type the  command " / ?" 

 

As  tasklist  can directly type tasklist / ?

 

 

 

Hit ENTER, then

 

 

 

 The detailed use of the command will appear, you can refer to the use of this method to write your own batch command, it is not very convenient

ok, first here, the next article revisit one instance.

-----Edit by Andy

 

 

 

 

Reproduced in: https: //www.cnblogs.com/tstcxxzx/archive/2013/05/05/3061485.html

Guess you like

Origin blog.csdn.net/weixin_34405354/article/details/93723450
Recommended