Batch Script How to Set Variabes inside another variable

谁说我不能喝 提交于 2020-01-17 05:03:25

问题


i want to do something like this

1.bat

var1=The bot now At %PlaceName%

2.bat

SET PlaceName=Hotan
Echo %var1%

it should be like:

The bot now At Hotan

but it is shown like:

The bot now At %PlaceName%

回答1:


1.bat

@echo off
setlocal

set "var1=The bot now At !PlaceName!"
call 2.bat

2.bat

@echo off
setlocal EnableDelayedExpansion

SET PlaceName=Hotan
Echo %var1%

Another way:

1.bat

@echo off
setlocal

set "var1=The bot now At %%PlaceName%%"
call 2.bat

2.bat

@echo off
setlocal

SET PlaceName=Hotan
call Echo %var1%


来源:https://stackoverflow.com/questions/36958759/batch-script-how-to-set-variabes-inside-another-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!