Dim WshObj

Dim fsoObj

Dim WinFolder

Dim hostsFile

 

Set WshObj = CreateObject("WScript.Shell")

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set fsoObj = CreateObject("Scripting.FileSystemObject")

WinFolder = WshObj.ExpandEnvironmentStrings("%SystemRoot%")

Set hostsFile = fsoObj.OpenTextFile(WinFolder & "\system32\drivers\etc\hosts", ForAppending, True)

 

hostsFile.WriteLine("192.168.255.255                     myhosts.com")

hostsFile.Close

 

Set WshObj = Nothing

Set fsoObj = Nothing