This line works:
findstr /I /C:"Archiving file" "..\LogFiles\%NewLogFileName%"
Outputting the following to the screen:
2023-08-21 13:25:11.9024|Info|Archiving file
The next line I am looking for ERROR
in a file. I know that ERROR
is NOT in the file, so my expectation is that the error level should be 1
, but it is continually 0
.
findstr /I /C:"ERROR" "..\LogFiles\%NewLogFileName%"
IF ERRORLEVEL 1 (
ECHO Error level AFTER Search %ERRORLEVEL%
)
What am I doing wrong?
Since this thread opened I have changed the code to:
findstr /I /C:"ERROR" "..\LogFiles\%NewLogFileName%"
call echo %%errorlevel%% & REM WORKS "1"
REM multiple iteration of these lines fail
REM Some things I have tried
echo %errorlevel% & REM FAILS "0"
SET "somevar=%%errorlevel%%"
echo %somevar% & REM FAILS "0"
The text files are basic text. one has Archiving file in the contents the other DOES NOT HAVE error in the text.
What more can I provide?