Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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 /fastdetectbut 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 /noguibootyou 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?

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
::== doneStir gently and season to taste.
M2

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

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

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

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=xxxxxxxto
[settings]
IP=yyy.yy.yy.yy
DSN=wwwwwwww

![]() |
![]() |
![]() |

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