I’m trying to setup a section of my script to test for specific ERRORLEVEL results and respond to the user accordingly.
I have the following that tests for what seems to be the error
-2147024891 (Access is Denied)
when trying to modify a file but it never triggers even though the !ERRORLEVEL!
on the line before reports the -2147024891 error.
CALL :TEE ERROR - ERROR# !ERRORLEVEL! occured on %me% - please check event logs for further details
IF !ERRORLEVEL! EQU -2147024891 (
CALL :TEE ERROR - Please make sure to run this script from an elevated command prompt
)
I have SETLOCAL enableDelayedExpansion
set therefore I am using !ERRORLEVEL!
rather than %ERRORLEVEL%
- but I am still a little unclear how delayedexpansion subtly changes the behavior of the script.
I understand the best way to check for specific numbers is to use the following but I am not sure how to do this for negative numbers.
IF ERRORLEVEL <N> IF NOT ERRORLEVEL <N+1> <COMMAND>
Any suggestions?