How to edit .ini file using batch script ??

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ihots
Posts: 1
Joined: 02 Sep 2014 18:46

How to edit .ini file using batch script ??

#1 Post by ihots » 02 Sep 2014 18:55

Hi Guys,

I am very new to batch scripting and i would like to know how could i modify my ini file using a batch script
This is exactly what i need to do:

Update values in Example.ini, the values that i need to update look something like this

[Cache]
Enabled = 1


[Log]
Enabled = 0

[Support]
Line1 = ÿ
Lines = 1
MailSenderAddress = Report@example.com

There is more content above and below these.
I would like my batch script to update [Log] value from 0 to 1 , i.e Enabled = 1
& delete value of MailSenderAddress = , it should be blank.

so updated values should look something like this


[Log]
Enabled = 1

[Support]
Line1 = ÿ
Lines = 1
MailSenderAddress =

I want to automate this so that i can include this batch script in another script (Master Script) which will run and update these values as well apart from its usual job that it does.

Could you guys please help me with this?

Cheers
irish


Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: How to edit .ini file using batch script ??

#3 Post by Samir » 07 Sep 2014 20:41

I'm not sure about the approach, but I think reading the ini into somewhat of an array where each setting below a heading would be identified as being part of that heading. Then you could search the array for the string you want, change it and then rebuild the complete ini file again.

Not an easy task, but I know there's several geniuses on here that can code this 100x faster than I can even think about it. :oops:

Post Reply