本帖最后由 Pia 于 2015-6-17 08:54 编辑
今天碰到一个问题, 从特定档案中提取特定变数
但是%USERPROFILE% 不会自动展开, 该如何修正呢?
得到的输出为
ADIR=GTAV_SAVE
BDIR=%USERPROFILE%\Documents\Rockstar Games\
请按任意键继续 . . .
希望得到这个输出, 要如何修改呢?
ADIR=GTAV_SAVE
BDIR=C:\Users\XXXX\Documents\Rockstar Games\
================ 读取外部文件.cmd =================- @echo off
- if exist Setting.ini set Setting_Files=Setting.ini
-
- findstr /b "ADIR" "%~dp0%Setting_Files%" >%TEMP%\temp.txt & for /f "delims== tokens=2*" %%i in (%TEMP%\temp.txt) do (set ADIR=%%i)
- findstr /b "BDIR" "%~dp0%Setting_Files%" >%TEMP%\temp.txt & for /f "delims== tokens=2*" %%i in (%TEMP%\temp.txt) do (set BDIR=%%i)
-
- echo ADIR=%ADIR%
- echo BDIR=%BDIR%
- PAUSE
复制代码 ================ 读取外部文件.cmd END=================
================Setting.ini==================
ADIR=GTAV_SAVE
BDIR=%USERPROFILE%\Documents\Rockstar Games\
================Setting.ini END================== |