Solved

Bat files programming

Posted on 2000-04-25
12
188 Views
Last Modified: 2010-04-16
I need to write a new value to a section of an ini file, using Batch file programming
0
Comment
Question by:duke_n
  • 6
  • 2
  • 2
  • +1
12 Comments
 
LVL 8

Expert Comment

by:shlomoy
ID: 2748317
And the problem is?
0
 
LVL 1

Author Comment

by:duke_n
ID: 2749361
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.
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2750282
BATCH as in DOS BAT files?
0
 
LVL 1

Author Comment

by:duke_n
ID: 2750477
Yeah.
THat's what I meant.
0
 
LVL 2

Expert Comment

by:Serega
ID: 2758539
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.
0
 
LVL 1

Author Comment

by:duke_n
ID: 2758821
but they will be added at THE END of the file.

I need them to be added into a specific section.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Expert Comment

by:Serega
ID: 2758881
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.
0
 
LVL 1

Author Comment

by:duke_n
ID: 2759195
I tried it and it didn't work.
0
 
LVL 1

Author Comment

by:duke_n
ID: 2759196
Serega,I tried your first suggestion  and it didn't work.
0
 
LVL 4

Accepted Solution

by:
arminl earned 20 total points
ID: 2763854
Batches don't support ini files, but there are tons of freeware tools available that do what you want, I even wrote one myself once:

ini /F:test.ini /S:testsection /K:Testvalue /V:"test value".

Makes a test.ini

[testsection]
Testvalue=test value

Additional parameters allow deletion of keys and sections. Exisitng values are automatically overwritten.

To grab a copy, download the Techseries Unattended Setup Tools Disk from www.adlon.de/akademie/techseries. the tool is included in the \Tools subdirectory. Freeware!.

Ic you don't get through to the disk (German page) send me your e-mail adress; and I'll mail you a copy. (armin.lidner@adlon.de).

Armin
0
 
LVL 1

Author Comment

by:duke_n
ID: 2765556
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.
0
 
LVL 4

Expert Comment

by:arminl
ID: 2765807
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.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 100
WMI, model #, retrieving information 10 91
wordcount challenge 11 75
Not needed 13 55
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now