How do you suppress environment variable expansion within DOS and Windows CMD?

后端 未结 2 777
借酒劲吻你
借酒劲吻你 2020-12-11 04:07

This is a simplified example with modified variable names of what I want to do. Also for simplicity sake, I am showing the command line version rather than the bat file ver

相关标签:
2条回答
  • 2020-12-11 04:37

    Within a batch file, use two %%s, e.g.:

    set foo=1
    echo %%foo%%
    

    ...echoes "%foo%", not "1". I'm not aware of a way to disable it in immediate mode (e.g., not in a batch file).

    0 讨论(0)
  • 2020-12-11 04:54

    in a batch file, echo %%foo%% will generate %foo%.

    c:\01Temp>type foo.bat
    @echo %%foo%%
    
    c:\01Temp>foo
    %foo%
    
    c:\01Temp>
    
    0 讨论(0)
提交回复
热议问题