Reputation: 26498
What is wrong with the below syntax:
@ECHO OFF
SET FLAG=TRUE
invalidcmd
call :checkERR "Duplicate Entry "
@ECHO %FLAG%
IF "%FLAG%" EQU "TRUE"(
@ECHO DONEXT
)
ELSE (
@ECHO INVALID
)
:checkerr
REM echo %ERRORLEVEL% with %1
IF NOT %ERRORLEVEL% == 0 (
@ECHO %1
SET FLAG=FALSE
REM EXIT /B %ERRORLEVEL%
)
Objective is if the %FLAG%
is FALSE
then it must echo INVALID
.
But I am getting the below output:
D:\ >installer.bat [hidden arguments]
'invalidcmd' is not recognized as an internal or external command, operable program or batch file.
"Duplicate Entry "
FALSE
The syntax of the command is incorrect.
Upvotes: 0
Views: 27
Reputation: 80023
IF
true-condition targetif
else
keyword must be on the same physical lineelse
keyword, a separator and the opening parenthesis of the "else" block must be on the same physical lineie
if condition (
something
) else (
someotherthing
)
Upvotes: 1