批处理文件以编辑

批处理文件以编辑

本文介绍了批处理文件以编辑.ini的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,.ini文件中的设置似乎会不断恢复.我发现自己一直在检查文件以查看是否需要编辑,因此我想看看是否可以拿出一个可以完成此工作的批处理文件.想法是创建此批处理文件,以每2分钟扫描一次.ini文件,以检查特定行的值,并在必要时更改该值.该行是:

I have a program for which a setting in the .ini file seems to constantly revert. I find myself constantly checking the file to see if it needs to be edited, so I would like to see if I can come up with a batch file that will do this job. The idea is to create this batch file to scan the .ini file every 2 minutes to check the value of a particular line and change the value if necessary. The line is:

UpdateSpeedCore = 8

UpdateSpeedCore=8

8是所需的支票号码,但有时会恢复为100.

8 is the desired number for the check, but it sometimes reverts to 100.

文件名为prolasso.ini,路径为C:\ Documents and Settings \ Administrator \ Application Data \ ProcessLasso \ config \ prolasso.ini.

The name of the file is prolasso.ini and the path is C:\Documents and Settings\Administrator\Application Data\ProcessLasso\config\prolasso.ini.

谢谢任何可以帮助您解决此烦恼的人...

Thankyou to anyone who can help with this annoyance...

有关.ini文件的更多信息.没有空行.但是,有些行将"="设置为无值,例如"Power =".文件中可能有六个分区描述符,例如"[Debug]"或"[AdvancedRules]".这些设置不等于值.它是静态长度线,大约100行长.除节轮廓符外,所有行均使用"="符号后跟一个值.这些名称的开头是"UpdateSpeedCore"中的设置名称.

More on the .ini file. There are no empty lines. However, there are some lines that are set "=" to no value like "Power=". There are maybe half a dozen section delineators in the file like "[Debug]" or "[AdvancedRules]". These are not set equal to a value. It's a static length lines wise and about 100 lines long. Other than the section delineators, all the lines use an "=" sign followed by a value. These are preceded by the setting name as in "UpdateSpeedCore".

推荐答案

这期望UpdateSpeedCheck=8本身在一行上,没有空格.

This expects the UpdateSpeedCheck=8 to be on a line by itself with no spaces.

它使用来自-的名为repl.bat的帮助程序批处理文件. http://www.dostips.com/forum/viewtopic.php?f=3&t=3855 ,您可以将其放在同一文件夹中.

It uses a helper batch file called repl.bat from - http://www.dostips.com/forum/viewtopic.php?f=3&t=3855 which you can put in the same folder.

@echo off
set "file=C:\Documents and Settings\Administrator\Application Data\ProcessLasso\config\prolasso.ini"

:loop
findstr "^UpdateSpeedCheck=8$" "%file%" >nul || (
type "%file%"|repl "^UpdateSpeedCheck=.*" "UpdateSpeedCheck=8" >"%file%.tmp"
move "%file%.tmp" "%file%" >nul
)
ping -n 120 localhost >nul
goto :loop

这篇关于批处理文件以编辑.ini的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 12:42