批处理代码: @echo off >tmp.ini set IniFn= ::在等号后面写上ini的文件名,如:set IniFn=configip.ini for /f "tokens=1* delims=:" %%i in ('findstr /n ".*" c:/Windows/%IniFn%') do ( if "%%j"=="" (echo.>>tmp.ini) else ( echo %%j|find "Item4=192.168.1.2">nul&&( call set tp=%%j&call echo %%tp:192.168.1.2=test.test.com%%>>tmp.ini)||( >>tmp.ini echo %%j) ) ) copy tmp.ini c:/Windows/%IniFn% /y >nul||(attrib -s -a -r -h c:/Windows/%IniFn%? tmp.ini c:/Windows/%IniFn% /y >nul) del tmp.ini pause @echo off (for /f "delims=" %%a in (a.ini) do ( set "str=%%a" setlocal enabledelayedexpansion set "str=!str:aaa=bbb!" echo,!str! endlocal ))>a.ini.tmp move /y a.ini.tmp a.ini