I need some help and I still don't know the best way to accomplish
this. I need to search a license file that is a regualr asci text file
c:\gadgets\test.lic file and replace a line in the c:\gadgets\test.lic
and save it. What is the easiest way to accomplish this? And do I
save it out to a .vbs extenion?

The line I need to search for is: SERVER="chicago"
IPADDRESS="192.168.1. 5"
The Line I need to replace with is: SERVER="corporate"
IPADDRESS="192.168.1.45"

Thanks for anyone who reads this and/or helps me out.
-C

RE: Search a text file and replace text vbscript by ESP

ESP
Fri Nov 04 14:45:22 CST 2005

Wow, nice name. Ummm, thx for the visual....NOT!

Reference
http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0208.mspx

ESP



"TeaBagger" wrote:

> I need some help and I still don't know the best way to accomplish
> this. I need to search a license file that is a regualr asci text file
> c:\gadgets\test.lic file and replace a line in the c:\gadgets\test.lic
> and save it. What is the easiest way to accomplish this? And do I
> save it out to a .vbs extenion?
>
> The line I need to search for is: SERVER="chicago"
> IPADDRESS="192.168.1. 5"
> The Line I need to replace with is: SERVER="corporate"
> IPADDRESS="192.168.1.45"
>
> Thanks for anyone who reads this and/or helps me out.
> -C
>
>

Re: Search a text file and replace text vbscript by Hal

Hal
Fri Nov 04 21:04:55 CST 2005


"TeaBagger" <y2kcmoore@gmail.com> wrote in message
news:1131119521.657594.255830@o13g2000cwo.googlegroups.com...
> I need some help and I still don't know the best way to accomplish
> this. I need to search a license file that is a regualr asci text file
> c:\gadgets\test.lic file and replace a line in the c:\gadgets\test.lic
> and save it. What is the easiest way to accomplish this? And do I
> save it out to a .vbs extenion?
>
> The line I need to search for is: SERVER="chicago"
> IPADDRESS="192.168.1. 5"
> The Line I need to replace with is: SERVER="corporate"
> IPADDRESS="192.168.1.45"
>
> Thanks for anyone who reads this and/or helps me out.
> -C

open the file for input and Read the file - a line at a time.
If the current line is NOT the one you are wanting to replace, then append
it to a String (which you will be using to replace the file with.)
If the current line IS the one you are replacing, append the OTHER line (the
replacement) to the string.
when finished reading the whole file and appending it all to the string,
close the file.
Then open the same file for output (nuking the contents)
write the string you just built to replace the contents of the file, then
close the file.
... then take a nap. collect the paycheck. and eat a steak.