DOS batch: SET variable and ECHO it within (…) block
问题 I had a problem with set not working in a batch file; it took a while to distil the problem; at first I thought it was to do with subroutine calls... The script @echo off setlocal set a=aaa echo a = "%a%" ( set b=bbb echo b = "%b%" ) produces the output a = "aaa" b = "" whereas I'd expect a = "aaa" b = "bbb" Why is this please? Is it a bug in DOS? Perhaps there's something about the (...) command grouping syntax that I'm unaware of. Thanks. 回答1: User delayed expansion and ! instead of % @echo