我的代码示例:
for /F "skip=0 delims=" %%i in (Settings.txt) do if not defined NewHDLocation set "NewHDLocation=%%i"&goto next
:next
for /F "skip=1 delims=" %%i in (Settings.txt) do if not defined WOTinstalldir set "WOTinstalldir=%%i"&goto next2
:next2
@echo %NewHDLocation%
@echo %WOTinstalldir%
pause
最后2个@echo只是测试它是否从txt中获取信息,但它只会输出:
C:\WINDOWS\system32>for /F "skip=0 delims=" %i in (Settings.txt) do if not defined NewHDLocation set "NewHDLocation=%i" & goto next
delims=" was unexpected at this time.
C:\WINDOWS\system32>for /F "skip=1 delims=" %i in (Settings.txt) do if not defined WOTinstalldir set "WOTinstalldir=%i" & goto next2
C:\WINDOWS\system32>if not defined WOTinstalldir set "WOTinstalldir=ECHO is on." & goto next2
ECHO is on.
ECHO is on.
C:\WINDOWS\system32>pause
Press any key to continue . . .
在我需要阅读的文本文件中(仅用于测试):
New_HDfiles_Drive
WOT_Install_Location
答案 0 :(得分:2)
在这种特殊情况下,我可能只是将文件流式传输到代码块中。
@ECHO OFF
<settings.txt (
set /p "NewHDLocation="
set /p "WOTinstalldir="
)
echo %NewHDLocation%
echo %WOTinstalldir%
pause