How to read ini files in windows batch?
Here: http://www.ericphelps.com/batch/sam…
i find some answer that not satisfy me. So i found better: (we read ini field to batch variable witch only one line of code!)
For example i chave config.ini file:
———————————————————-StartFIle
[Remote Machines]
RemoteMachineCompile=”aaaabbb.ccc”
RemoteMachineBuild=”dddd.eee”
RemoteMachineTest=”dfffff.ffffe”
———————————————————-EndFile
The answer is:
———————————————————-StartFile
@call:ini RemoteMachineBuild var
@echo walue of RemoteMachineBuild is: %var%
@pause
@goto:eof
@REM Function below read config.ini file form current direcotry.
@REM It have 2 parameters:
@REM %~1 – name of readed ini field,
@REM %~2 – name var to save readed value.
:ini
@for /f “tokens=2 delims==” %%a in (‘find “%~1=” config.ini’) do @set %~2=%%a
@goto:eof
———————————————————-EndFile
Well, this is random.