在括号内转动回声

在以下示例中,echo on 将在到达括号上下文结束后生效:

@echo off
(
    echo on
    echo ##
)
echo $$

为了在括号上下文中激活echo(包括 FORIF 命令),你可以使用 FOR / f 宏

@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 ###
)