在括號內轉動回聲

在以下示例中,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 ###
)