Batch file fails to set environment variable within conditional statement

后端 未结 3 1395

Why does the following Windows Batch File output Foo followedby Bar, rather than Baz?

@echo off
setlocal

set _=Foo
echo %         


        
3条回答
  •  一整个雨季
    2021-02-13 10:54

    The answer to this is the same as the answer to:Weird scope issue in batch file. See there for more details. Basically variable expansion is done at line read time, not at execution time.

提交回复
热议问题