The difference between errorlevel and%errorlevel% in BAT _dos/bat

Source: Internet
Author: User
Tags error code

They are all judged by the return value of the last command.
When using an if ERRORLEVEL value cmmand a sentence, it means that if the error code value returned is greater than or equal to the value, the Cmmand

Operation

When using an if%errorlevel%== value cmmand a sentence, it means that if the error code value returned is equal to the value, the Cmmand action is performed.

In general, the result of the previous command returned only two values, "success" in 0 means "failed" in 1, in effect, the ERRORLEVEL return value can be
Between the 0~255,

For example, Xcopy defaults to a ERRORLEVEL value of 5, representing 5 execution states respectively:

0 Copy file Success
1 copy File not found
2 user terminated xcopy operation via CTRL C
4 initialization error occurred
5 A disk write error has occurred

If%errorlevel% the numerical comparison method is not limited to equals, you can use parameters to control it.

For example: IF%errorlevel% leq 1 goto okay

All the comparison parameters are as follows:
EQU-equals
NEQ-Not equal to
LSS-Less than
Leq-less than or equal to
GTR-Greater than
GEQ-greater than or equal to

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.