1. MS-DOS and Windows command line if command

          Updated: 05/21/2018 by Computer Hope
          if command

          The if command performs conditional processing in batch programs.

          Availability

          The if command is an internal command accessed and used in batch files.

          If syntax

          Windows Vista and later syntax

          IF [NOT] ERRORLEVEL number commandIF [NOT] string1==string2 commandIF [NOT] EXIST filename command
          NOTSpecifies that Windows 2000 or XP should carry out the command only if the condition is false.
          ERRORLEVEL numberSpecifies a true condition if the last program run returned an exit code equal to or greater than the number specified.
          string1==string2Specifies a true condition if the specified text strings match.
          EXIST filenameSpecifies a true condition if the specified filename exists.
          commandSpecifies the command to carry out if the condition is met. Command can be followed by the ELSE command that will execute the command after the ELSE keyword if the specified condition is FALSE.

          The ELSE clause must occur on the same line as the command after the IF. For example:

          IF EXIST filename. ( del filename.) ELSE ( echo filename. missing.)

          The example below would NOT work because the del command needs to be terminated by a newline:

          IF EXIST filename. del filename. ELSE echo filename. missing

          Nor would the example below work, because the ELSE command must be on the same line as the end of the IF command:

          IF EXIST filename. del filename.ELSE echo filename. missing

          The example below would work if you want it all on one line:

          IF EXIST filename. (del filename.) ELSE echo filename. missing

          If Command Extensions are enabled IF changes as follows:

          IF [/I] string1 compare-op string2 commandIF CMDEXTVERSION number commandIF DEFINED variable command

          where compare-op may be one of:

          • EQU - equal
          • NEQ - not equal
          • LSS - less than
          • LEQ - less than or equal
          • GTR - greater than
          • GEQ - greater than or equal

          and the /I switch, if specified, says to do case insensitive string compares. The /I switch can also be used on the string1==string2 form of IF. These comparisons are generic, if both string1 and string2 are composed of all numeric digits, then they're converted to numbers and a numeric comparison is performed.

          The CMDEXTVERSION conditional works like ERRORLEVEL, except it is comparing against an internal version number associated with the Command Extensions. The first version is 1. It will be incremented by one when significant enhancements are added to the Command Extensions. CMDEXTVERSION conditional is never true when Command Extensions are disabled.

          The DEFINED conditional works like EXISTS except it takes an environment variable name and returns true if the environment variable is defined.

          %ERRORLEVEL% expands into a string of the current value of ERRORLEVEL, provided there is not already an environment variable with the name ERRORLEVEL, in which case you get its value. After running a program, the example below illustrates ERRORLEVEL use:

          goto answer%ERRORLEVEL%:answer0echo Program had return code 0:answer1echo Program had return code 1

          You can also use the numerical comparisons below:

          IF %ERRORLEVEL% LEQ 1 goto okay

          %CMDCMDLINE% expands to the command line passed to CMD.EXE before any processing by CMD.EXE, provided there is not a CMDCMDLINE environment variable, in which case you get its value.

          %CMDEXTVERSION% expands into a string of the value of CMDEXTVERSION, provided there is not already an environment variable with the name CMDEXTVERSION, in which case you get its value.

          Windows XP and earlier syntax

          Performs conditional processing in batch programs.

          IF [NOT] ERRORLEVEL number commandIF [NOT] string1==string2 commandIF [NOT] EXIST filename command
          NOTSpecifies that Windows should carry out the command only if the condition is false.
          ERRORLEVEL numberSpecifies a true condition if the last program run returned an exit code equal to or greater than the number specified.
          commandSpecifies the command to carry out if the condition is met.
          string1==string2Specifies a true condition if the specified text strings match.
          EXIST filenameSpecifies a true condition if the specified filename exists.

          If examples

          See the batch file help page for additional examples and uses of the choice command.

          Additional information

          • See our if else definition for further information and related links on this term.

              1. http://www.ri2bj2r4.tw | http://m.ri2bj2r4.tw | http://wap.ri2bj2r4.tw | http://3g.ri2bj2r4.tw | http://4g.ri2bj2r4.tw | http://5g.ri2bj2r4.tw | http://mobile.ri2bj2r4.tw | http://vip.ri2bj2r4.tw | http://ios.ri2bj2r4.tw | http://anzhuo.ri2bj2r4.tw | http://0b.ri2bj2r4.tw | http://4f.ri2bj2r4.tw | http://86a.ri2bj2r4.tw | http://0.ri2bj2r4.tw | http://cb1cd0.ri2bj2r4.tw | http://edd9c.ri2bj2r4.tw | 真爱禁区影评