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.
Batch file to remove strings
Name: Blindness Date: December 9, 2008 at 12:20:03 Pacific OS: na CPU/Ram: na Product: N/a / NA
Comment:
Hello,
I'm not sure this is the right section, because I need this script to work on XP, but batch programing is somewhat more DOS realted.
So I'm looking for a batch script which deletes certain lines from a file. To be exact: I made a file which add 2 new lines to /windows/system32/drivers/etc/hosts. An example: 1.2.3.4 www.asite.com 1.2.3.4 www.anothersite.com
Let's say this is the "installer" of something. Now I also need an "uninstaller", which remove these lines. My first idea was to make a backup of the file and then restore it at the uninstall but other lines, added later would also lost.
Name: Mechanix2Go Date: December 10, 2008 at 07:44:53 Pacific
Reply:
If there are just 2 lines of interest and you have them in a text file named added, try this script below. You could extend it some but if there were a whole slew of lines it would get unweildy.
========= remove2.bat @echo off & setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (added) do ( set /a N+=1 set v!N!=%%a )
Summary: Hi, How can I write a batch file to restrict others to use Internet Explorer and Yahoo Messenger on my system. Please help me in this regard. Sweetie. ...
Summary: I have a folder that I want to back-up to an external hard drive. Anytime I write new data to this folder, I want a copy sent to the HD. I have found a batch file to do just about everything...but t...