Delayed variable expansion from .BAT

  • Thread starter Thread starter Ondrej Sevecek
  • Start date Start date
O

Ondrej Sevecek

Hello,
is there a method to TURN ON the delayed variable expansion from inside a
BAT file? This can be achieved through the command line switch of CMD.EXE
/V:ON, but I would like to create BAT file without making users start CMD
with such a switch.

Nice day

Ondra.
 
Ondrej Sevecek said:
Hello,
is there a method to TURN ON the delayed variable expansion from inside a
BAT file? This can be achieved through the command line switch of CMD.EXE
/V:ON, but I would like to create BAT file without making users start CMD
with such a switch.

@echo off & setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
set "str=hello"
echo/Before: [!str!]
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
echo/After : [!str!]
echo/Press any key to learn about the SETLOCAL command... & pause>nul
setlocal/?|more
 
Back
Top