I noticed that string comparison in a batch file doesn't work properly if you compare against words like "IF" and "DO".
IF "DO" == "DO" (
ECHO YES
)
The above works fine, but isn't useful.
SET stringDO=DO
IF %stringDO% == "DO" (
ECHO YES
) ELSE (
ECHO NO
)
When we use a variable, the result for the above example is "NO"
Strangely, comparing 2 variables works fine.
SET stringDO=DO
SET compare=DO
IF %stringDO% == %compare% (
ECHO YES
)
So my question is, am I doing anything wrong or is this an intended behavior?
Is there another way to escape command words in string comparisons?