Link to home
Start Free TrialLog in
Avatar of duke_n
duke_n

asked on

Bat files programming

I need to write a new value to a section of an ini file, using Batch file programming
Avatar of shlomoy
shlomoy

And the problem is?
Avatar of duke_n

ASKER

In a BAT file!!!!!!!
How do I do that?
The way I know the bat file programming is real primitive.

I wanted to know how to do that.
BATCH as in DOS BAT files?
Avatar of duke_n

ASKER

Yeah.
THat's what I meant.
I think easyest way to do it will be the following:
1) prepare little Your.ini file with block of needed values.
2) add it to Target.ini file by perfoming command:
copy Target.ini + Your.ini Target.ini

As a result you'll have ini file with your values succesfully added.
Avatar of duke_n

ASKER

but they will be added at THE END of the file.

I need them to be added into a specific section.
I suppose that it will be enough for your puposes.
Almost all programs can to view settings even they are in different places of .ini file but with the same name of the section.
But if you want to insert them into the specific place, you can at first to split target file and then to paste 3 files together. But I don't know how to split first file.
Avatar of duke_n

ASKER

I tried it and it didn't work.
Avatar of duke_n

ASKER

Serega,I tried your first suggestion  and it didn't work.
ASKER CERTIFIED SOLUTION
Avatar of arminl
arminl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of duke_n

ASKER

The reason I wanted to use batch files is because I need it to be the smallest there is(and work in DOS, ofcourse). Otherwise, I can write something by myself.

Now, If your proggy works in DOS and is 50K or smaller, please send it to duke_n5@hotmail.com. Otherwise please withdraw your answer.
The tool is just 13k in size. And, sure, everyone who can use a compiler can write everything himself, but why should he if someone else already has?

Using external tools to overcome batch limitations is common practice, even Microsoft does, e.g. when you use the choice external command,. or any I/O filter like find or sort.

What you can also do is store the tool right where you store your batch file, and then use the %0\..\ trick to call it:

...
...
%0\..\ini /F:.....
....
....

This neat technique works with any MS OS I've seen, and reliefs you from having to put tools somewhere in your search path, or call them using a fixed path. Works over networks as well!

Anyway. pure Batch won't give you what you want, because it lacks everything you'd need for editing an ini structured file. Believe me. 15 years of batch file programming experience speaking.

....Armin

P.S. won't be online again till next Saturday.