I’ve spent some time poking around stackoverflow and the net in general looking for a well described answer to this problem.
I have a piece of software that installs itself and reads a .ini file. This .ini is of variable size and variable line numbers. The style of every line is something like the following:
setting1=contents
setting2=more,contents
setting3=different type of contents
setting4=youget/theidea
I need to search this text file for a few specific lines, let’s say it’s the following:
Username=Tommy
Servername=HAL2000
And then replace the values after the equals sign (i.e. change Tommy to Timmy). My problem is that all of the scripting I’ve found and tried to incorporate either sees the values above as a variable (i.e. username becomes a variable with value “Tommy”) or when I go to replace Tommy with timmy, the .ini file ends up replacing EVERY line in the file with Username=Tommy.
I’ve since deleted both of these scripts and moved on, but the more I think about it the more I want to go back and do this script.
Only rule is that is HAS to be in Windows command line with commands native to XP. No third party programs, no python, no perl, nothing but Windows command line that can be run out of a .bat file.
This is going to be clumsy, but if the number of keys to be replaced is limited, the following might be enough for you: