Batch Read INI file

Source: Internet
Author: User
Tags read ini file

INI file read using method:
     inifile IniFilePath [section] [item]                   &N Bsp    Example:                               & nbsp                                inifil E c:\boot.ini                               &NB Sp             Read all C:\Boot.ini [section]               & nbsp               inifile c:\boot.ini "[boot loader]"         &NBS P                   read C:\Boot.ini [boot loader] section       &N Bsp                 inifile c:\boot.ini "[boot loader]" Timeout                     show c:\boot.ini [boot loader] Segment timeout value  
@echo off Setitem=SetFilepath=Setsection=setlocalenabledelayedexpansionif  not"%~1" = = "" (SetFilepath=%1)Else Goto : File_errif  not exist%filepath%Goto : File_errif  not"%~2" = = "" (Setsection=%2        if"!section:~0,1!" ==""^"Set section=!section:~1! If"!section:~-1!" ==""^"SetSection=!section:~0,-1!)Else Goto : sectionif  not"%~3" = = "" (Setitem=%3        if"!item:~0,1!" ==""^"Set item=!item:~1! If"!item:~-1!" ==""^"SetItem=!item:~0,-1!)setlocaldisabledelayedexpansionSetField start = for/F "Usebackq delims=[]"%%i in ('Find/i "%section%"/n%filepath% ') Do SetField start =%%i for/F "Usebackq tokens=1* delims== skip=% field start%"%%i in ('type%filepath% ') Do(SetA=%%isetlocalenabledelayedexpansionif"!a:~0,1!" =="["Goto : EOF        if  not"!a:~0,1!" ==";" (setlocaldisabledelayedexpansion for/F "delims=;"%%x in ("%%i=%%j") Do(if  notDEFINED Item (Echo%%x)Else(if/I "%%i" = = "%item%"Echo%%x))))Goto : EOF : sectionsetlocaldisabledelayedexpansion for/F "Usebackq delims== skip=2"%%i in ('Find/i "["%filepath% ') Do Echo%%iGoto : EOF : File_errsetlocaldisabledelayedexpansionEcho.Echo %1file not found or not entered!Echo.Goto : EOF

Batch Read INI file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.