::Special Feature Available
SET testAvailable=1
::Copy a needed module
SET modulName=Module
XCOPY %moduleName%\%targetHardware%\%moduleName%\Debug\%modulName%.bin %target%
::Copy additional module if needed
IF %test1Available%==1 (
SET moduleName=TestModule1
XCOPY %moduleName%\%targetHardware%\%moduleName%\Debug\%modulName%.bin %target%
)
I am trying to copy different files from a folder-structure into another folder. Everything works fine until I try to add "special features", which I set before. (Set TestAvailable=1 or 0).
Now the batch runs into the if statement and even runs the xcopy ... But with the moduleName from before (Module instead TestModule), copying the same file again.
If I add another IF with TestModule2, the script will copy TestModule1 instead of TestModule2. And so on.
It is working if I use:
IF %Test1Available==1 SET ...
IF %Test1Available==1 XCOPY ...
I already tried to add
SETLOCAL enableDelayedExpansion
without any luck.
Why won't the variables inside the IF-statement be updated and instead it uses the old variables from before the IF-statement?