how to read ini files in win batch?

December 23, 2010 at 02:32:56
Specs: Windows 7
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


See More: how to read ini files in win batch?

Report •

#1
December 23, 2010 at 05:34:15

Report •
Related Solutions


Ask Question