hostnames = "172.16.1.134 portal.yosungroup.com,172.16.1.134 eip.yosungroup.com,172.16.1.181 tpedisap1.yosungroup.com,172.16.1.182 tpedisap2.yosungroup.com,172.16.1.183 tpecrmap1.yosungroup.com,172.16.1.184 tpecrmap2.yosungroup.com,172.16.1.196 tpebpmap1.yosungroup.com,172.16.1.197 tpebpmap2.yosungroup.com,172.16.1.200 tpebpmweb1.yosungroup.com,172.16.1.202 tpenotes2.yosungroup.com,172.16.1.235 tpenotes5.yosungroup.com,172.16.1.245 tpeap1.yosungroup.com,172.16.99.245 tpeap8.yosungroup.com,172.23.1.201 sznotes1.yosungroup.com,192.168.123.231 hknotes1.yosungroup.com,10.86.30.2 shnotes1.yosungroup.com" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = WScript.CreateObject("Wscript.Shell") path = objShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath") what = Split(hostnames, ",") Set WriteHosts = objFSO.CreateTextFile("WriteHosts.bat", True) WriteHosts.WriteLine("copy /y " & path & "\hosts " & path & "\bak_hosts") For i = 0 To UBound(what) If i = 0 Then WriteHosts.WriteLine("echo " & ip & " " & what(i) & "> " & path & "\hosts") Else WriteHosts.WriteLine("echo " & ip & " " & what(i) & ">> " & path & "\hosts") End If Next WriteHosts.WriteLine("del /f /q WriteHosts.bat") WriteHosts.Close() run = objShell.Run("WriteHosts.bat", 0, True)