日期:2014-05-17 浏览次数:21707 次
@echo off & setlocal enabledelayedexpansion set "f=" set "i=" for /f "delims=" %%a in (config.ini) do ( set v=%%a if "!v:~0,1!"=="[" ( if %%a==[Common] (set f=1) else (set "f=") ) else ( if defined f ( for %%b in (%%a) do ( if %%b==ITEM2 (set f=2) else (if !f!==2 set i=%%b&&goto readover) ) ) ) ) :readover if defined i (echo ITEM2=%i%) set "f=" (for /f "delims=" %%a in (config.ini) do ( set v=%%a if "!v:~0,1!"=="[" ( if %%a==[Common] (set f=1) else (set "f=") echo.%%a ) else ( if defined f ( if defined i ( if "%%a"=="ITEM2=%i%" (echo ITEM2=test2) else echo.%%a ) else ( set "f=" echo.%%a echo ITEM2=test2 ) ) else echo.%%a ) ))>config.ini2 move config.ini2 config.ini pause