[批處理]ini檔案讀取

來源:互聯網
上載者:User
@echo offset item=set filepath=set section=setlocal EnableDelayedExpansionif not "%~1"=="" (        set filepath=%1) else goto :file_errif not exist %filepath% goto :file_errif not "%~2"=="" (        set section=%2        if "!section:~0,1!"==""^" set section=!section:~1!        if "!section:~-1!"==""^" set section=!section:~0,-1!) else goto :sectionif not "%~3"=="" (        set item=%3        if "!item:~0,1!"==""^" set item=!item:~1!        if "!item:~-1!"==""^" set item=!item:~0,-1!)setlocal disableDelayedExpansionset 欄位開始=for /f "usebackq delims=[]" %%i in (`find /i "%section%" /n %filepath%`) do set 欄位開始=%%ifor /f "usebackq tokens=1* delims== skip=%欄位開始%" %%i in (`type %filepath%`) do (        set a=%%i        setlocal EnableDelayedExpansion        if "!a:~0,1!"=="[" goto :eof        if not "!a:~0,1!"==";" (                setlocal disableDelayedExpansion                for /f "delims=;" %%x in ("%%i=%%j") do (                        if not DEFINED item (echo %%x) else (if /i "%%i"=="%item%" echo %%x)                )        ))goto :eof:sectionsetlocal disableDelayedExpansionfor /f "usebackq delims== skip=2" %%i in (`find /i "[" %filepath%`) do echo %%igoto :eof:file_errsetlocal disableDelayedExpansionecho.echo %1檔案未找到或未輸入!echo.goto :eof

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.