Requirements: The original host has increased the following 3 lines
202.102.101.105 Intranet.corp
202.102.101.107 Mail.intranet.corp
202.102.101.108 Sip.intranet.corp
This 3-line content is not required, so run the above VBS code to delete the host file 3 lines
' This script requires the execution user to have local Administrator privileges Const ForReading = 1, ForWriting = 2, ForAppending = 8, ReadOnly = 1 Set fso = CreateObject ("Scripting . FileSystemObject ") Set wshshell=createobject (" Wscript.Shell ") ' Windir for Windows installation directory windir = WSHShell.ExpandEnvironmentStrings ("%WinDir%") ' Set host file directory Hostsfile = windir & ' \system32\drivers\etc\hosts ' Check that the host file is read-only and, if read-only, modify the file properties set objFSO = CreateObject ("Scripting.FileSystemObject") Set objfile = Objfso.getfile ( Hostsfile) If objfile.attributes and ReadOnly Then objfile.attributes = objfile.attributes Xor ReadOnly End If Set objf so = CreateObject ("Scripting.FileSystemObject") Set objfile = objFSO.OpenTextFile (hostsfile, Forreading,true) ' Check if the host file has changed, and if so, the script hostfileline= "" do Until objfile.atendofstream strline = objfile will no longer be executed. ReadLine If InStr (strline, "202.102.101.105") <> 0 or (INSTR (strline, "202.102.101.107")) <>0 Or (InStr (Strl INE, "202.102.101.108")) Then strline= "" "End If hostfileline=hostfileline+vbcrlf+strline Loop WSCRIpt. Echo hostfileline objfile.close ' Modify host file Set Filetxt = fso. OpenTextFile (Hostsfile, ForWriting) filetxt. Write hostfileline Filetxt.
Close Wscript.Quit