level 2
比如:
a.bat和a.txt在同一目录
a.txt的内容为:
%windir%
a.bat的内容为:
@ echo off
cd /d %~dp0
type a.txt
pause
运行a.bat,显示内容为:%windir%
但我想要显示内容为%windir%的变量值,也就是C:\Windows,a.txt内容不能变,要怎么用bat实现?
2023年05月20日 11点05分
1
level 9
type仅读取,获取变量值可用for+call
for /f "delims=" %%a in ('type a.txt') do call set "value=%%a"
echo;%value%
pause
2023年05月28日 06点05分
2
call 可以,感谢
2023年05月28日 15点05分