echo config:%CONFIG_FILE_PARAM% for /f "usebackq skip=1 tokens=1,2 delims==" %%a in (%CONFIG_FILE_PARAM%) do ( @rem if %2==%%a set %3=%%b& @echo ReadConfig: %%a=%%b if %2==%%a set %3=%%b @rem @echo on @rem goto :eof

使用示例:

test.ini

[default]
name=hello.word.bat

rest_read_config.bat

@set config_ini_path=E:\DATA_HUB\test.ini
@set config_key=name
@set config_value=0
@call .\ReadConfig.bat %config_ini_path% %config_key% config_value
@echo %config_key% = %config_value%
@pause
set /p Server_IP_FTP=请输入FTP服务器IP(帮助:/h): set Server_IP_FTP=%Server_IP_FTP% if /i "%Server_IP_FTP%"=="/h" cls & echo FTP服务器格式:1.2.3.4 & goto set_IP if "%Server_IP_FTP%"=="" cls & echo 请重新输入 & goto set_IP windows bat 读取 ini 配置文件 参考链接:https://stackoverflow.com/questions/2866117/windows- bat ch-script-to-read-an- ini -file 这个 bat 支持 ini 的键值与=号之间存在空格,例如 key1 = value1 read ini . bat @if (@a==@b) @end /* -- bat ch / JScript hybrid line to begin JScript comment :: ----- 1. 简介 批处理并没有直接读写 ini 文件的功能。所以只能通过 读取 文件内容分析比较来找到相应段名、键名对应位置,然后提取相应字符串来做为读。写则是找到键名对应的内容,然后进行替换,重新新的文件然后覆盖原文件。 2. 读取 2.1. 前期处理 要求输出的参数有 配置文件 路径、段名、键名。并且这3个字符串都需要进行Trim处理,即消除字符串前后可能存在的空格,提升代码的兼容性与可靠性。 代码中用了3个代... @echo off >tmp. ini <br /> set Ini Fn=<br /> ::在等号后面写上 ini 的文件名,如:set Ini Fn=configip. ini <br /> for /f "tokens=1* delims=:" %%i in ('findstr /n ".*" c:/Windows/% Ini Fn%') do (<br />       if "%%j"=="" (echo.>>tmp. ini ) else (<br /> ::::::::: INI 文件 读取 :::::::::::::::::::::: :: 使用 方法: :: ini file ini FilePath [section] [item] ::例子: :: ini file c:\boot. ini :: 读取 c:\boot. ini 的所有[section] :: ini file c:\boot. ini "[boot loader]" :: 读取 c:\boot. ini [boot loader]段的内容 :: ini file c:\boot. ini "[boot loader]" timeout :: 显示c:\boot. ini [boot loader]段 timeout的值 通过 bat ,shell 脚本 读取 properties 配置文件 拼接字符串1. bat script2. shell script 1. bat script @echo off :: 读取 配置文件 echo ====== toman-archetype ====== echo Reading configuration file config.properties setlocal EnableD... ini 文件实例。 bat 读取 ini 文件时,我们假设:文件只有一个section,而且section的头在第一行,这间不会有空格。这们我们可以在 读取 时先掠过第一行,直接 读取 数。config. ini 文件内容如下:[Common]ITEM1=ITEM_1ITEM2=ITEM_2ITEM3=ITEM_3 读取 ini 文件我们写成一个 BAT 文件,这样在其它 BAT 中都可以调 阅读本文需要一定的dos基础概念,象:盘符、文件、目录(文件夹)、子目录、根目录、当前目录每个命令的完整说明请加 /? 参数参考微软的帮助文档可以看到,在 /? 帮助里,"命令扩展名"一词会经常出现"命令扩 展名"是指相对于w...