Windows bat (batch processing)-basic syntax

Source: Internet
Author: User

Windows bat (batch processing)-Basic Syntax 1. @ the first line of the command will not be displayed. 2. echo2.1 echo [{on | off}] [message] output, echo. 2.2 on | off it is actually a switch command, that is, it has only two States: open and close. So there are two commands, echo on and echo off. (1) echo off only displays execution results (2) echo on (default) displays execution commands (except echo) and execution results (3)> output redirection to create or clear files, then output the data to the echo hi> a.txt file and append the data to the file echo this is a text> a.txt echo hi> a.txt type a.txt echo this is a text> a.txt type a.txt 3. note: or rem 4. ":" And goto (1) Go to tag (2): define a tag Sample: [python] if {% 1 }={} goto noparms if {% 2 }={} goto noparms (if you do not understand if, % 1, and % 2 here, jump over first, and a detailed explanation will be provided later .) @ Rem check parameters if null show usage: noparms echo Usage: monitor. bat ServerIP PortNumber goto end 5. when running the Pause command, the following message is displayed: [python] Press any key to continue... sample: [python] @ echo off: begin echo Pause pause goto begin 6. the Call command calls another batch processing program from one batch processing program without terminating the parent batch processing program. The call Command accepts the labels used as the call target. If a Call is used outside a script or batch file, it does not work in the command line. Syntax call [Drive:] [Path] FileName [BatchParameters] [: label [arguments] parameter [Drive:} [Path] FileName specifies the location and name of the batch program to be called. The filename parameter must have the. bat or. cmd extension. 7. The start command calls external programs. All DOS commands and command line programs can be called by the start command. Common Intrusion parameters: at the start of MIN, the window minimization SEPARATE starts in a SEPARATE space for 16-bit Windows programs. HIGH starts in the HIGH priority category. Application REALTIME starts in the REALTIME priority category. Application WAIT starts the application and waits until it ends. parameters these are the 32-bit GUI applications that are used to execute parameters transmitted to the command/program, CMD. the command prompt is returned when the application is terminated. If it is executed in the Command Script, the new behavior will not occur. 8. choice command choice uses this command to allow users to enter a character to run different commands. The/c: parameter should be added for use, and c: should be followed by a prompt to enter characters without spaces. Its return code is 1234 ...... For example, choice/c: dimethyl defrag, mem, and end will display defrag, mem, end [D, M, E]? Sample: Sample. bat content: @ echo offchoice/c: dimethyl defrag, mem, endif errorlevel 3 goto defrag (the highest error code should be determined first) if errorlevel 2 goto memif errotlevel 1 goto end: defragc: dosdefraggoto end: memmemgoto end: endecho good bye after this file is run, defrag, mem, end [D, M, E] is displayed. You can select d m e, and then the if statement will make a judgment. d indicates the program segment with the execution label as defrag, and m indicates the program segment with the execution label as mem, e indicates the program segment whose execution label is end. Each program segment finally jumps the program to the end label using goto end. Then, the program displays good bye, and the file ends. 9.% x parameter % 1 -- 1st parameters % 2 -- 2nd parameters % 3 -- 3rd parameters ....net use \ % 1 \ ipc $ % 3/u: "% 2" % 1 -- IP % 2 -- username % 3 -- password

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.