In the following example echo on
will take effect after the end of the brackets context is reached:
@echo off
(
echo on
echo ##
)
echo $$
In order to "activate" echo on in a brackets context (including FOR
and IF
commands) you can use FOR /f macro :
@echo off
setlocal
:: echo on macro should followed by the command you want to execute with echo turned on
set "echo_on=echo on&for %%. in (.) do"
(
%echo_on% echo ###
)