Expanding environment variables for command prompt

后端 未结 1 1168
滥情空心
滥情空心 2021-01-20 15:33

I would like to run a cmd.exe that would evaluate environment variables at call time instead of when it parses the command. If I set the BASE to 2 and echoing it, I should s

相关标签:
1条回答
  • 2021-01-20 15:56

    This should work for you:

    cmd.exe /X /V:ON /C "set BASE=2&&echo !BASE!&&pause"

    /V:ON enables Delayed Expansion of variables, which is what you need here. Order of the switches (/V:ON /C) matters.

    0 讨论(0)
提交回复
热议问题