bat ini文件读取

借助《bat 读取 ini 文件》文章中的readini.bat实现(请自行前往下载),可满足多个section下Key值查询。

ini文件示例

[Server]
ServerName    =127.0.0.1

读取Server下的ServerName

set section1="Server"
set key1="ServerName"
for /f "delims=" %%a in ('call readini.bat /s section1 /i key1 "ini文件路径"') do ( set test=%%a )

or

for /f "delims=" %%a in ('call readini.bat /s "Server" /i "ServerName" "ini文件路径"') do ( set test=%%a )

  

 注意:ini文件编码类型需指定为”ANSI“,否则读取失败

原文地址:https://www.cnblogs.com/ylhssn/p/11237751.html