![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-15 12:30 |
47,812 topics / 349,917 posts / today 0 new / 48,268 members |
| DOS批处理 & 脚本技术(批处理室) » Ask - How to modify the parameter values in an ini file without opening it |
| Printable Version 5,235 / 11 |
| Floor1 hisean | Posted 2006-04-05 12:14 |
| 新手上路 Posts 2 Credits 8 | |
|
There is such a requirement. I want to modify the assignment of a certain parameter in the INI file through the command line method, but I don't want to perform manual operations such as manual search and replace through notepad, edit, etc. This parameter is unique in the name in the INI, but the line number is not fixed.
|
|
| Floor2 3742668 | Posted 2006-04-05 13:24 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
```
@echo off for /f "delims=: tokens=1,2" %%i in ('"findstr /n . 123.txt"') do set %%i=%%j & set col=%%i for /f "delims=:" %%m in ('"findstr /n /c:"Content" 123.txt"') do set num=%%m set /a var = num - 1 for /l %%n in (1,1,%var%) do echo %%%%n%% | findstr . >>tmp.txt echo %%%num%:Content=new content%% | findstr . >>tmp.txt set /a var = var + 2 for /l %%e in (%var%,1,%col%) do echo %%%%e%% | findstr . >>tmp.txt ``` Just modify it yourself, that's the principle. |
|
| Floor3 hisean | Posted 2006-04-05 14:17 |
| 新手上路 Posts 2 Credits 8 | |
|
Heheh, thanks, big shot, but I still don't get it. I'll take it back and study it carefully.
|
|
| Floor4 Climbing | Posted 2006-04-05 18:04 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
If there are no objections to using third-party tools, then using tools like Horst's VarSet or inifile is simpler.
|
|
| Floor5 Kinglion | Posted 2006-04-05 19:01 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
Agree with the statement above.
|
|
| Floor6 3742668 | Posted 2006-04-05 20:51 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Wait... wait, I want to raise a... quibble.
If using a third-party tool, like using VBS, it's flexible and simple, follow me... Save as "Modify ini file.vbs", then directly drag the file to be modified onto it, and then follow the prompts. If you double-click it directly, a dialog box will open for you to select the file to be modified. By default, it only replaces once. If you want to replace multiple times, you can modify the last 1 in the fourth last line to another number by yourself. It seems off-topic, this is the DOS forum, my comrades. |
|
| Floor7 willsort | Posted 2006-04-06 03:20 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re 3742668:
The burden needs two people to carry, I'll also help a bit ![]() First, vbs can be supported by the cscript that comes with Windows, so it can't be regarded as "third-party"; second, vbs is a scripting language, and "tools" can only be its supporting programs, such as cscript; third, modifying ini is not string replacement, because usually we modify variables according to the variable names in ini rather than variable values or variable names + variable values; finally, if you don't want to solve the problems of the DOS forum, then your CMD script should also retire. In addition, before using inifile and VarSet, I also compiled similar batch code under DOS, but unfortunately I can't find it now, and rewriting has no strong purpose. |
|
| Floor8 3742668 | Posted 2006-04-06 19:09 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Re willsort:
Since it's a quibble, I still need to continue. First of all, in view of my shameful typo in the 6th floor, it caused Brother willsort to have a misunderstanding that I regarded VBS as a third-party tool. In fact, my original words should be "If using a third-party tool, it's better to use VBS, flexible and simple, follow me...", please note that the word at the 10th offset is "not", so Brother willsort's first quibble is invalid. Second, due to not understanding the spirit of the owner's question, it caused a wrong purpose of the script. But from another perspective, only a little modification of my two scripts can achieve the requirement, giving the owner the opportunity to write by himself. Of course, if someone says that my script has strong portability, I have no objection. Finally, the phrase "hanging up the official hat and retiring" makes me feel that it doesn't seem to be a quibble. Besides, CMD and DOS seem to be similar, and they are of the same origin, so it's not too far-fetched to count as DOS. |
|
| Floor9 Climbing | Posted 2006-04-06 21:01 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Both of you are masters at arguing. My admiration for both of you is also like a continuous torrent of water...
|
|
| Floor10 DOSforever | Posted 2006-04-06 21:13 |
| 金牌会员 Posts 2,239 Credits 4,639 | |
Originally posted by Climbing at 2006-4-6 21:01: Hahahahaha…… Although I don't understand anything, Xiao Ke, you are getting cuter and cuter. Come on, let me give you a kiss Hahahahaha…… |
|
| Floor11 willsort | Posted 2006-04-06 21:55 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re All:
Let's stop the fruitless arguments. As the saying goes, "A little argument is enjoyable, but too much is harmful." Therefore, we won't go into the complex relationship between CMD and DOS in detail. It should be brought to everyone's attention that recently, there have been a large number of threads discussing Windows NT command scripts in the "DOS Difficulties & Problem Discussions (Q&A Room)" here. While this can certainly greatly promote the communication and development of Windows NT command scripts, due to the principle of apical dominance in horticulture, other types of discussion topics are inevitably affected in a restrictive way. In the long run and from a overall perspective, this is not beneficial to the development of the CNDOS forum. Therefore, it is suggested that more users actively post and reply to other types of topics to comprehensively promote the construction and development of the forum. Thank you for your cooperation! |
|
| Floor12 Climbing | Posted 2006-04-07 13:59 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Up to now, there is really not too many new topics to discuss about pure DOS, what do you think, Brother wil?
So far, as soon as it comes to pure DOS, basically it's about how to drive USB devices? How to play a game? How to optimize memory? Or problems like serial port reading and writing. Basically, either it can't be solved, or it has been discussed too much. Don't talk about how different cmd is from DOS. After all, cmd still belongs to the DOS category, don't attack me, this is what I think. I still have my original opinion, focus on practicality, not metaphysics. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |