批处理脚本如何在另一个变量中设置Variabes

时间:2016-04-30 18:40:01

标签: batch-file batch-processing

我想做这样的事情

1.BAT

var1=The bot now At %PlaceName%

2.bat

SET PlaceName=Hotan
Echo %var1%

应该是这样的:

The bot now At Hotan

但显示如下:

The bot now At %PlaceName%

1 个答案:

答案 0 :(得分:0)

<强> 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%

另一种方式:

<强> 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%