'// Add server(s) to client host file
Option Explicit
Dim sFile, sHost, sSysDir, oHost
Dim oFSO, sCheck
Const WindowsFolder = 0
Const ForReading = 1
Const ForAppending = 8
sFile = "\system32\drivers\etc\hosts"
Set oFSO = CreateObject("Scripting.FileSystemObject")
'// Get the %system% folder
Set sSysDir = oFSO.GetSpecialFolder(WindowsFolder)
sHost = sSysDir & sFile
Set oHost = oFSO.OpenTextFile(sHost, ForReading, False)
sCheck = oHost.readall
If instr(sCheck, "server.whatever.com") = 0 Then
oHost.close
wscript.sleep 500
Set oHost = oFSO.OpenTextFile(sHost, ForAppending, False)
oHost.writeline vbcrlf
oHost.writeline "x.x.x.x" & vbTab & "server.whatever.com"
End If
oHost.close