The batch processing function is very powerful. Below I wrote a script that can read the ini configuration file.
------------------------------ Readini. Bat ---------------------------------------------
Rem @ echo off & setlocal enabledelayedexpansion
Number of REM echo parameters: % 0% 1% 2% 3
Set Name =
Set namelist =
Set Param =
Set paramlist =
For/F "EOL =; tokens = 1 * usebackq delims =" % I in (% 1) Do (
Rem echo % I % J
Set P = % I
Rem echo P =! P!
Rem echo character! P! ! P :~ 0, 1! ! P :~ -1! ! P :~ 1,-1!
If "! P :~ 0, 1! "= "["(
If "! P :~ -1! "="] "(
Rem @ echo condition! P :~ 1,-1!
Set Name =! P :~ 1,-1!
)
)
Rem echo name =! Name! Namelist =! Namelist! Paramlist =! Paramlist! Enter % 2
If "" = "% 2 "(
Rem echo namelist =! Namelist! % I
If! Namelist! Equ ""(
If "! P :~ 1,-1! "NEQ ""(
Rem echo Step 1! Namelist!
Set namelist =! P :~ 1,-1!
)
) Else (
If "! P :~ 1,-1! "NEQ ""(
Rem echo Step 2 UUUU! Namelist! UUUU
Set namelist =! Namelist !,! P :~ 1,-1!
)
)
) Else if "! Name! "=" % 2 "(
If "% 3" = ""(
If "[! Name!] "NEQ" % I "(
If "! Paramlist! "= ""(
Set paramlist = % I
) Else (
Set paramlist =! Paramlist !, % I
Rem echo returns the property % I % J.
)
)
) Else (
If "% I" = "% 3 "(
Set Param = % J
)
)
)
)
Rem echo ------------------------
Rem echo name =! Name!
If "% 2" equ ""(
Rem Name List
Echo "! Namelist :~ 1! "
) Else (
If "% 3" equ ""(
Rem attribute list
Echo "! Paramlist! "
) Else (
Rem Attribute Value
Echo "! Param! "
)
)
Rem @ echo on
Bytes ----------------------------------------------------------------------------------------
------------------------------- 1. ini ---------------------------------------------
; INI file for testing
Note that the name cannot contain equal signs or spaces.
There cannot be a space between the attribute and the equal sign
[ABC]
Cd = OOP
Me = KKE = d F
[BBB]
Cd = WSD
Me =
----------------------------------------------------------------------------------
------------------- Call method test. Bat ----------------------------------------
@ Echo off & setlocal enabledelayedexpansion
Echo ---- readini 1. ini ----
Call readini 1.ini
Echo ---- readini 1.ini ABC ----
Call readini 1.ini ABC
Echo ---- readini 1.ini ABC me ----
Call readini 1.ini ABC me
@ Echo on
Pause
Bytes -----------------------------------------------------------------------------------
Running Effect