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