surely something is amiss
I thought I understood the benefits of using a legacy, stable technology for simple tasks. I'm executing this DOS command:
test.bat test Policy:
while the contents of test.bat are:
Code:
@ECHO ON
SETLOCAL EnableDelayedExpansion
SET RESULT=%2
IF '%RESULT%' == 'Policy:' SET RESULT=0
SET CHK=%RESULT:~0,16%
SET RC=%RESULT:~-10%
ECHO %RESULT% %CHK% %RC%
IF '%CHK%' == 'An error occurred' (
ECHO %RC%
EXIT /B %RC%
)
REM
and I get this:
Code:
Z:\WindowsSandbox\tools>SETLOCAL EnableDelayedExpansion
Z:\WindowsSandbox\tools>SET RESULT=Policy:
Z:\WindowsSandbox\tools>IF 'Policy:' == 'Policy:' SET RESULT=0
Z:\WindowsSandbox\tools>SET CHK=0
Z:\WindowsSandbox\tools>SET RC=0
Z:\WindowsSandbox\tools>ECHO 0 0 0
0 0 0
Z:\WindowsSandbox\tools>IF '0' == 'An error occurred' (
Z:\WindowsSandbox\tools>ECHO 0
0
Z:\WindowsSandbox\tools>EXIT /B 0
Z:\WindowsSandbox\tools>
Why does the IF compare result in the error exit? Thanks in advance for any clarity you can provide.
Win11, 25H2. (the latest)