windows - How to set a variable with an environment variable read from a text file -
i've created following config file contains parameters used batch file:
file winscp.conf:
folder %appdata%\winscp version 5.7.4 visit http://sourceforge.net/projects/winscp/files/winscp/ download http://sourceforge.net/projects/winscp/files/winscp/5.7.4/winscp574.zip
batch file (get.bat):
@echo off setlocal @if not exist "%1" ( echo config file not found in "%1" exit /b ) @for /f "tokens=1,2 delims= " %%a in (%1) ( set %%a=%%b ) mkdir %folder%
when call batch file this:
get.bat winscp.conf
i sub-folder %appdata%\winscp created in current folder, this:
c:\temp\%appdata%\winscp
while want winscp folder created in windows app data folder, this:
c:\users\caffe\appdata\roaming\winscp
i think there's wrong statement set %%a=%%b
, since if change set %%a=%appdata%\winscp
folder created way want.
the variables inside tokens should expanded prior assignment adding call
:
call set %%a=%%b
Comments
Post a Comment