DOS batch: SET variable and ECHO it within (…) block

后端 未结 3 1241
梦毁少年i
梦毁少年i 2021-02-05 23:31

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 sc

3条回答
  •  遇见更好的自我
    2021-02-05 23:48

    You need delayed expansion to be on, or the batch interpreter will interpolate all variables at parsing time, instead of run time.

    setlocal enableextensions enabledelayedexpansion
    

    See this question for an example and some great explanation of it.

提交回复
热议问题