Computing.Net > Forums > Programming > Editing .ini file with a batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Editing .ini file with a batch file

Reply to Message Icon

Name: brendon.pilott
Date: February 7, 2005 at 18:22:19 Pacific
OS: XP
CPU/Ram: P4 2.8 1GB
Comment:

I need to create a batch file that adds text to the last line in an .ini file.

The .ini file is C:\boot.ini which usually looks like:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect

but i need it to look like:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /bootlogo /noguiboot

you see the last two flags at the end of the last line are new. how do i do this in a batch so that i do not have to manually edit the .ini file?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: February 7, 2005 at 21:26:56 Pacific
Reply:

Hi brendon,

First you create the file:

line.4

which contains the new last line with desired flags.

Then you run this batch:

::== new line 4
find /v "fastdetect" < boot.ini > boot.1
copy/b boot.1+line.4 boot.new
copy/b boot.new boot.ini
::== done

Stir gently and season to taste.


M2


0

Response Number 2
Name: brendon.pilott
Date: February 8, 2005 at 13:39:10 Pacific
Reply:

That did exactly what i needed thanks,

another question, how can i compare say line 4 from the boot.ini file with a test file and kill the program if they are different?

ie: i do not wan to overwrite this line with a slightly different one as the pc might not boot afterwards.

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect


0

Response Number 3
Name: Mechanix2Go
Date: February 9, 2005 at 19:16:27 Pacific
Reply:

Hi brendon,

Not quite sure what you're asking, but in general, to compare two lines and quit [kill the program ?] if different:

::==
@echo off > quit.bat
set /p old=<oldline
set /p new=<newline
if not %OLD%'==%NEW%' quit
::==


M2


0

Response Number 4
Name: chipw
Date: March 2, 2005 at 07:56:56 Pacific
Reply:

Question, I am beginner when it comes to creating batch files. When you say create the file, i assume you mean , create the ini file, and the characters in that creation, I want to make sure i have them right. what are the characters after the two colons:: and how were those created.

I need to do this for a default.ini file for a program called simply safe backup. I need for the file to add the %username% variable for a particular user, but in the ini file itself, when i use %username% it does not recognize that shortcut.

Thanks


0

Response Number 5
Name: Richard2112
Date: March 4, 2005 at 07:56:12 Pacific
Reply:

need to edit line an ini file as part of an install, by running a batch. Is this possible please?

e.g change

[settings]
IP=xx.xx.xx.xx
DSN=xxxxxxx

to

[settings]
IP=yyy.yy.yy.yy
DSN=wwwwwwww


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Editing .ini file with a batch file

Editing a Text File With a Batch www.computing.net/answers/programming/editing-a-text-file-with-a-batch/14889.html

editing text file with a batch file www.computing.net/answers/programming/editing-text-file-with-a-batch-file/16828.html

need a batch file www.computing.net/answers/programming/need-a-batch-file/13744.html