标题: [文本处理] 批处理如何修改ini文件的指定值 [打印本页]
作者: yym黄诗瑶 时间: 2017-9-28 14:39 标题: 批处理如何修改ini文件的指定值
- @echo off & setlocal enabledelayedexpansion
- set ListenPort=0
- set IsSupport=0
- goto dealmanager1
- set EableCall=1
- set EableOneMoreCall=1
- set Eable60P=0
- goto dealmanager2
- set Conference_Module=Meeting
- goto dealmanager3
- :dealmanager1
- (for /f " delims=:" %%h in ('findstr /n "." "!SourcePath!\Config\CoreDefConfig.ini"') do (
- set "str=%%i"
- if "!str:ListenPort=!" neq "%%i" (
- echo ListenPort=!ListenPort!
- ) else if "!str:IsSupport=!" neq "%%i" (
- echo IsSupport=!IsSupport!
- ) else (
- echo,%%i
- )
- ))>"!SourcePath!\Config\2.ini"
- del "!SourcePath!\Config\CoreDefConfig.ini"
- rename "!SourcePath!\Config\2.ini" "CoreDefConfig.ini"
- :dealmanager2
- (for /f "tokens=1* delims=:" %%h in ('findstr /n "." "!SourcePath!\Config\I7DefConfig.ini"') do (
- set "str=%%i"
- if "!str:EableCall=!" neq "%%i" (
- echo EableCall=!EableCall!
- ) else if "!str:EableOneMoreCall=!" neq "%%i" (
- echo EableOneMoreCall=!EableOneMoreCall!
- ) else if "!str:Eable60P=!" neq "%%i" (
- echo Eable60P=!Eable60P!
- ) else (
- echo,%%i
- )
- ))>"!SourcePath!\Config\3.ini"
- del "!SourcePath!\Config\I7DefConfig.ini"
- rename "!SourcePath!\Config\3.ini" "I7DefConfig.ini"
-
- :dealmanager3
- (for /f "tokens=1* delims=:" %%h in ('findstr /n "." "!SourcePath!\Module.ini"') do (
- set "str=%%i"
- if "!str:Conference_Module=!" neq "%%i" (
- echo Conference_Module=!Conference_Module!
- ) else (
- echo,%%i
- )
- ))>"!SourcePath!\4.ini"
- del "!SourcePath!\Module.ini"
- rename "!SourcePath!\4.ini" "Module.ini"
-
- pause
复制代码
替换文本内容,只有第一个dealmanager1修改成功,第二个dealmanager2修改失败,等号后面没有值,为空。第三个deal也有问题,很奇怪。
作者: 见与不见 时间: 2017-10-14 00:33
帖子沉了,居然没有人回帖
作者: 老刘1号 时间: 2017-10-14 12:10
本帖最后由 老刘1号 于 2017-10-14 12:12 编辑
批处理修改INI文件函数块+用法+实例
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |