Below is a BAT file sample which shows a curious behaviour. When a "SET" is used inside () an IF statement we get an error, if we have other code besides a SET then no problem.
I created a work around by doing the SET on the IF line and doing the other logic I need in a normal
IF
... (
stuff ) ELSE (
more )
Does someone know what is going on here?
NB: Same outcome if SETLOCAL is used
::SETLOCAL ENABLEDELAYEDEXPANSION
echo **This works**
@set InstallerTest=false
@IF "%InstallerTest%"=="true" @SET SESign_Exe=%ProgramFiles(x86)%\Schneider Electric\CodeSign\signtrue.exe
@IF NOT "%InstallerTest%"=="true" @SET SESign_Exe=%ProgramFiles(x86)%\Schneider Electric\CodeSign\signfalse.exe
SET SESign_Exe
ECHO **THIS PRODUCES NO ERROR**
@IF "%InstallerTest%"=="true" (
echo IN TRUE PART
) ELSE (
ECHO IN FALSE PART
)
echo **this produces : \Schneider was unexpected at this time.**
@IF "%InstallerTest%"=="true" (
SET SESign_Exe=%ProgramFiles(x86)%\Schneider Electric\CodeSign\signtrue.exe
) ELSE (
SET SESign_Exe=%ProgramFiles(x86)%\Schneider Electric\CodeSign\signfalse.exe
)
::ENDLOCAL