I have a cmd file. It receives two input parameters. The first parameter is the product name and the second the version.
I have a string variable that I create and initialize to a string with value "false" and then depending if some conditions are satisfied I update this variable to "true".
Finally I have a conditional in which I check if the value of the string variable is "true". The problem is that the comparison in this conditional fails so it does not enter within the conditional.
I have put an echo just before this conditional and it outputs an empty string.
below the piece of code:
@ECHO OFF
IF /I "%~1"=="product_C" (
REM DO sth
) ELSE (
IF /I "%~1"=="product_D" (
REM Do sth
) ELSE (
SET "product_a_or_b=false"
IF /I "%~1"=="Product_A" (
SET "product_a_or_b=true"
)
IF /I "%~1"=="Product_B" (
REM I have checked that this conditional is satisfied and enters here with an ECHO.
SET "product_a_or_b=true"
)
REM Below if-conditional is not satisfied despite I set the variable to "true" in the previous ifs
IF "%product_a_or_b%"=="true" (
ECHO "It is product A or B"
)
)
)