Windows batch common directives-continuous updates

Source: Internet
Author: User
Tags goto

Directive 1FunctionNoteRemCommentsThe following hints can be echoed and can be @echo off::Note, you cannot echoValid designator: A string that begins with an alphanumeric character followed by a colon, which can be identified by a goto statement. Invalid label: The colon immediately followed by a non-alphanumeric special symbol, goto unrecognized label, can play the role of annotation, so:: Often used as an annotation symbol, in fact: + can also play an annotated roleEchoTurn on echo or turn off echo featureOn/off, to turn off echo off itself, plus @, the command echo is turned off, regardless of whether ECHO is open at this time.Echo.Output a spaceEquivalent to a carriage return, can be used,:; "/[]+ any symbol instead ofecho File contents > file nameecho File contents >> file nameThe first one is overlay, the second one is appendPauseStops the execution of the system command and displays the following contentDisplay a custom prompt: Echo other tips & Pause > nulSetDefining variablesSet var=10:: = number cannot have spaces on either sideSetDefining variablesSet var=:: Assigning a variable is defining a variable, not assigning a value to a variable similar to a logout variableset/a expressionAllows the set to support mathematical symbols for addition and subtraction, and some other mathematical operationsset/p Var=[promptstring]Wait for user inputSet displays all current system environment variables, and set C displays all current variables beginning with C or C (case insensitive)ErrorlevelProgram return codeSuccessfully returned 0, failed 1TitleSet the title of CMDcolor [attr]Set the default console foreground and background colorSpecifies the color properties of the console output

The color attribute is specified by two hexadecimal digits-the first is the background and the second is the foreground. Each number can be one of any of the following values:
0 = Black 8 = Gray
1 = Blue 9 = light Blue
2 = green A = Light green//Case insensitive
3 = Lake Blue B = Light Green
4 = Red C = Light Red
5 = Purple D = Lavender
6 =xxxe = Light XXX
7 = White F = Bright White

Example: Color FC
If no parameters are given, the command restores the color to CMD. The color at which EXE starts. This value is from the current console window, the/T switch, or the DefaultColor registry value. If you use the same foreground and background color to execute the color command, the color command sets ERRORLEVEL to 1

Goto jump to the marking point Goto Label--: Label
Start Opens a new window to run the program If the new window does not exit properly, your batch will not execute properly.
Pager command can call another batch during batch execution When another batch finishes executing, continue with the original batch
%n
pushd Save the current directory, set the specified directory as the current directory
popd The directory that was last called pushd as the current directory

Multi-Select function

set/p choice= Please select:
if/i "%choice%" = = "1" Goto IP
if/i "%choice%" = = "2" goto Setsave
if/i "%choice%" = = "3" goto Kaiji
if/i "%choice%" = = "4" goto clean
if/i "%choice%" = = "Q" goto ENDD

The main benefit of the Taskkill command is that with many filters, you can end the process in bulk
/F forcibly End process
The/PID process ID specifies the PID of the processes to be terminated.

Common Special Symbols
1, @ command-line Echo mask
2,% Batch variable guide
3. > Redirection character
4. >> redirection character
5, <, >&, <& redirection
6, | Command pipe character
7. ^ Escape character
8. & Combination Command
9. && Combination Command
10, | | Combo command
11, "" String delimiter
12., comma
13,; Semicolon
14, () brackets
15,! Exclamation number
16. Other special tokens that may be seen in batch processing: (slightly)
CR (0D) command line terminator
Escape (1B) ANSI escape character guide
Space (20) commonly used parameter specifiers
Tab (09); = Non-commonly used parameter qualifiers

    • Copy command file connector
    • ? File wildcard characters
      /Parameter Switch guide
      : Batch Label Guide

Windows batch common directives-continuous updates

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.