Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

DOS command dictionary seven


May 23, 2021 DOS Command learning manual



2:if command and variable Basic format:

IF (not) errorlevel digital command statement If the program runs and finally returns an exit code equal to or greater than the specified number, the specified condition is True.

Example: IF errorlevel 0 command refers to the value returned by the program after execution is 0, on the command after the value line, IF not errorlevel 1 command refers to the program to execute the last returned value is not equal to 1, the execution of the later command.

0 refers to discovery and successful execution (true);

If the specified text string matches (i.e., string 1 equals string 2), the subsequent command is executed.

Example: "if "%2%""4" goto start": If the second variable entered is 4, execute the following command (note: when the variable is called, add %variable name % and """)

IF (not) exist file name Command statement If the specified file name exists, execute the subsequent command.

Example: "if not nc.exe goto end" means that if no nc .exe the file jumps to the ":end" label.

IF (not) errorlevel digital command statement else command statement or IF (not) string 1 , string 2 command statement else command statement or IF ( not exist ) file name Command statement else command statement plus: else command statement after: the condition of the current face is not true, it refers to the line else after the command. N ote: Else must be on the same line as if to be valid. W hen there is a del command, you need to include all the contents of the del command with a single line, because the del command can only be executed on a single line, and then it is equivalent to a single line; for example, "if exist test.txt. t he ".txt.", note the command ".txt."