Batch file: Enable delayed expansion From: EnableDelayedExpansion - Windows CMD - SS64.com EnableDelayedExpansion Delayed Expansion will cause variables within a batch file to be expanded at execution time rather than at parse time , this option is turned on with the SETLOCAL EnableDelayedExpansion command.