Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I once knew a way to insert some text into a document using a batch file(i know it sounds strange..!) and im sure i used the COPY command or something like that. Could someone shed some light on this for me?
Example:
Say i wanted to add a line to an INI file like (eg) RUN=Welcome.exe into the win.ini file?
I'm sure someone will know what im geeting at! Thanks!
AlI once knew a way to insert some text into a document using a batch file(i know it sounds strange..!) and im sure i used the COPY command or something like that. Could someone shed some light on this for me?
Example:
Say i wanted to add a line to an INI file like (eg) RUN=Welcome.exe into the win.ini file, and I wanted it to OVERWRITE the current RUN= line?
I'm sure someone will know what im getting at! Thanks!
Al

PS-Sorry but i pasted the darn thing in twice(!) Ignore the top bit, the second one is the one i want you to read..
Thanks!

I think the append command along with the pipe command, been a long time;
append welcome.exe | win.ini
or something along those lines. Sorry to be vague(sp?) on this but it might spark some memory cells. Rediirect > might be in there too.

This sounds very familiar...copy con filename
then type your text (up to 127 chr), enter for a new line.
F6 or CTRL-Z to close
To append output to a file:
'command' >>filename
for example, if you wanted the help text for a command:xcopy /? >help.txt
would create 'help.txt' with the screen output from 'xcopy /?'
If there already exists 'help.txt' - it will be overwritten!
xcopy /? >>help.txt
would 'append' or keep adding to the 'help.txt' file.
(You don't have to have a space between the redirect arrows and the target file, but you can if you want to)
xcopy /? >> help.txt
is ok too.
Is this what you're looking for?

Well, I think he was looking for something else.
Let me see if I've got it: you want the line to be automatically put into a file, overwriting the similar line that was there.
Here's how to do it.
I'll need EDLIN.exe. You may get it here:
http://filebox.vt.edu/users/alrobin2/home/edlin/download.html
(dont be scared with the page)(put it in a directorypath, such as c:\windows)It's a batch file. I will use the same example you did. The batch will also use a complementar file, also posted below.
----------------------------------------
----------------------------------------
contents of string.bat:@echo off
find /n /i "RUN=" c:\file.ini> out.bat
edlin out.bat [lessthan] string.rep >nul
echo SET LINE=%%1> string2.bat
call out.bat
echo %line%> string2.rep
echo RUN=Welcome.exe>> string2.rep
echo e>> string2.rep
edlin c:\file.ini [lessthan] string2.rep >nul
del out.bat
del string2.bat
del string.rep----------------------------------------
contents of string.rep:1,#r[^Zcall string2.bat,
1,#r]^Z,
e----------------------------------------
----------------------------------------NOTE1: ^Z means CTRL+Z character. You may get it at dos edit by CTRL+P+Z
NOTE2: [lessthan] means the lessthan character (the opposite of ">"). This forum has problems in posting it....That's it. Any further questions, mailme.
I have sent this to your email also.-- Secret_Doom --
email: secret_doom@hotmail.com

OOOOOOOPS!
I have made a mistake. The string.bat from last post is wrong. This one is right:@echo off
type file.ini |find /n /i "RUN=" > out.bat
edlin out.bat [lessthan] string.rep >nul
echo SET LINE=%%1> string2.bat
call out.bat
echo %line%> string2.rep
echo RUN=Welcome.exe>> string2.rep
echo e>> string2.rep
edlin file.ini [lessthan] string2.rep >nul
del out.bat
del string2.bat
del string2.rep
del out.bak
del file.bakNow it's ok and well tested!
sorry

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

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