BAT INI

来源:互联网 发布:stl源码剖析怎么样 编辑:程序博客网 时间:2024/06/01 23:33

批处理代码:

@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

原创粉丝点击