Question : Auto-update "HOSTS" file for Windows OS

All,
I may have this in the wrong Zones and if so I will ask the Mods to move it.

In an Article I wrote (http://www.experts-exchange.com/articles/Digital_Living/Software/MALWARE-An-Ounce-of-Prevention.html) one of the great 'tools' discussed was the modified "HOSTS" file that is freely available to everyone.

It is published here: http://www.mvps.org/winhelp2002/hosts.htm

This is a great tool, widely used all over the world - but the user must manually download and install it every time there is an update (once/twice a month).

My question (finally) is: "Can an application be developed to check the website monthly and 'auto-install' the HOSTS file?"

Note that different versions of Windows store this file in different folders - and that Vista and Windows 7 both have some extra hoops to jump through to actually do the installation.

This is a kind of 'starter' question and I am willing to open additional questions as needed - and/or move this around to an appropriate Zone.

Thank you for reading this and please give me some guidance for going forward.

Vic

Answer : Auto-update "HOSTS" file for Windows OS

Well below is a VBS script which works fine on my XP machine.

All you have to do is to save it as a text file (named vbs_download_hosts with VBS extension) and at the command prompt type in :

cscript vbs_download_hosts.vbs

which you would most likely incorporate into a batch job which can then do the unzip (which I suppose we can also do in vbs or jscript), and then include the updates as recommended on the website. You will need to make it "privileged" to run in Vista - there is even an Article in EE on how to do that (will try to find it)...

Anyway, hope it helps... Or at least is a start....

(edit small updates refinements)

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
strURLsource = "http://www.mvps.org/winhelp2002/hosts.zip"
strSaveAs = "C:\\ee\\newhosts.zip"
 
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
Set objFileSystem = Createobject("Scripting.FileSystemObject")
Set objADOStream = CreateObject("ADODB.Stream")
 
If objFileSystem.Fileexists(strSaveAs) Then objFileSystem.DeleteFile strSaveAs
 
objXMLHTTP.open "GET", strURLsource, false
objXMLHTTP.send()
 
If objXMLHTTP.Status = 200 Then
 
   objADOStream.Open
   objADOStream.Type = 1 
   objADOStream.Write objXMLHTTP.ResponseBody
   objADOStream.Position = 0 
   objADOStream.SaveToFile strSaveAs
   objADOStream.Close
 
End if
 
Set objADOStream = Nothing
Set objFileSystem = Nothing
Set objXMLHTTP = Nothing
Random Solutions  
 
programming4us programming4us