Delayed variable expansion from .BAT

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.
 
R

Ritchie

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top