I created this script to automate the process of updating your hosts file from the list contained on http://www.someonewhocares.org/hosts/. Using this hosts file is the best way I have found to "make the internet not suck (as much)" just like it claims to.
The VBScript downloads the web page to a local temp file, parses it so only comments and wanted lines are contained, then puts this file in the proper directory. It also creates a backup copy of the hosts file, and sets the new one to read-only. Just double-click to execute it or if the "all was successful" echo is removed from the end, then it may be run as a Windows scheduled task. I have tested it on Windows 2K, 2003, and XP.
Prevention is better than cleaning, and being able to use hotmail without the "Win Free DVD Player" ad flashing in your face is priceless. Every IT guy should use this!
Set objFSO = CreateObject("Scripting.FileSystemObject")
dim bFolder, strHostsPath
bFolder = objFSO.folderExists("C:\WINDOWS\")
if bFolder = False then
strHostsPath = "C:\WINNT\system32\drivers\etc\"
strHostsPath = "C:\WINDOWS\system32\drivers\etc\"
Set TempWebFile = objFSO.CreateTextFile("C:\Temp.html", 2)
While objIE.Busy: Wend
set PageText = objFSO.GetFile("C:\temp.html")
set ts = pagetext.OpenAsTextStream(1,-2)
Set OutFile = objFSO.OpenTextFile("C:\temp.txt",2,True)
Do while not ts.AtEndOfStream
ReadLine = ts.readline
ResultLine = InStr(Readline, "127.0.0.1")
ResultComment = InStr(Readline, "#")
if (ResultLine = 1) or (ResultComment = 1) _
or (ReadLine = "") then
Set objHostsFile = objFSO.GetFile(strHostsPath + "hosts")
objHostsFile.Attributes = 0
set BackFile=objFSO.GetFile(strHostsPath + "hosts")
BackFile.Copy strHostsPath + "hosts.bak"
NewFile.Copy strHostsPath + "hosts"
objHostsFile.Attributes = 1
WScript.Echo "Your Hosts File Has Been Updated Successfully!"