IF ERRORLEVEL
command.IF ERRORLEVEL 1 ECHO error level is 1 or more
<sidebar>
IF ERROR LEVEL n
works if the error level is n or higher . This is probably because many programs express varying degrees of error with large and large exit codes. For example, the diff program has 3 exit codes: β0β means that the files are the same, β1β is different, β2β - something terrible happened. Some programs use exit code β0β for success and everything else for error.</sidebar>
ERRORLEVEL
, if you wish, just as you can create a variable called FRED
. But, like FRED
, this variable will not affect the level of the error.rem this next command sets the error level to zero
CMD /C EXIT 0
set ERRORLEVEL=1
if ERRORLEVEL 1 echo Does this print?
ERRORLEVEL
variable has no effect on the error level. It is simply a variable whose name matches the concept of the command processor.set BANKBALANCE=$1 000 000,00
%ERRORLEVEL%
.%ERRORLEVEL%
with the current value of the internal error level. This is a backup option - how to specify a neighbor's address as a spare shipping address, in case you are not at home. However, this will not affect the parcels delivered to the neighbor.%CD%
: if you have not set a variable with the same name, the current directory of the command processor is substituted. But you cannot change the directory with set CD=C:\Windows
.ECHO error level is %ERRORLEVEL%>logfile
IF %ERRORLEVEL% EQU 1 echo Different!
Source: https://habr.com/ru/post/41028/
All Articles