Aggiungere un server nel file Hosts con uno script

Uno script che aggiunge una riga con un server nel file hosts controllando che non esista.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
hostsFile = objShell.ExpandEnvironmentStrings("%SystemRoot%") & "\system32\drivers\etc\hosts"
strIP = "10.5.5.10"
strValue = "CONTOSO"
 
If objFSO.FileExists(hostsFile) Then
    Set objTextFile = objFSO.OpenTextFile(hostsFile, ForReading)
Else
    Set myFile = objFSO.CreateTextFile(hostsFile, True)
    myFile.WriteLine "127.0.0.1       localhost"
    myFile.WriteLine strIP & " " & strValue
    Wscript.Quit
End If
 
strFlag = 0
Do Until objTextFile.AtEndOfStream
    strLine = Trim(objTextFile.ReadLine)
    If InStr(strLine, strIP) > 0 Then
        If InStr(strLine, strValue) > 0 Then
            strFlag = "1"
        End If
    End If
Loop
objTextFile.Close
 
If strFlag = 0 Then
    Set objTextFile = objFSO.OpenTextFile(hostsFile, ForAppending)
    objTextFile.WriteLine vbCrLf & strIP & " " & strValue
End If