Why does %errorlevel% not work with an "if" statement?
Posted: 14 Apr 2012 13:43
Okay, this is really frustrating...
If I use the following three lines by themselves, it works as expected:
As soon as I put this within a condition, the %errorlevel% command no longer works (see below). I am certain the condition is met before expecting the stuff within the parenthesis to work. How can I get %errorlevel% to behave correctly within a condition statement? Or, at least find the correct way to get the below logic to work:
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
If I use the following three lines by themselves, it works as expected:
Code: Select all
find /c "<errors>0</errors>" %recentBK%
if %errorlevel% equ 1 set today=failed
echo %today%
As soon as I put this within a condition, the %errorlevel% command no longer works (see below). I am certain the condition is met before expecting the stuff within the parenthesis to work. How can I get %errorlevel% to behave correctly within a condition statement? Or, at least find the correct way to get the below logic to work:
Code: Select all
if %BKfiledate%==%date% (
find /c "<errors>0</errors>" %recentBK%
if %errorlevel% equ 1 set today=failed
echo %today%
)