復制代碼 代碼如下:
Sub download(url,target)
Const adTypeBinary = 1
Const adTypeText = 2
Const adSaveCreateOverWrite = 2
Dim http,ado
Set http = CreateObject("Msxml2.ServerXMLHTTP")
http.SetOption 2,13056
http.open "GET",url,False
http.send
Set ado = createobject("Adodb.Stream")
ado.Type = adTypeBinary
ado.Open
ado.Write http.responseBody
ado.SaveToFile target,adSaveCreateOverWrite
ado.Close
End Sub
Set WshShell=CreateObject("WScript.Shell")
WinDir =WshShell.ExpandEnvironmentStrings("%WinDir%")
HostsFile = WinDir "\System32\Drivers\etc\Hosts_google"
Const hosts="https://raw.githubusercontent.com/vokins/simpleu/master/hosts"
download hosts,HostsFile
經(jīng)測試,由于網(wǎng)絡(luò)問題,可能獲取會超時,建議大家多運行幾次?;蚣尤肽_本可執(zhí)行時間。
您可能感興趣的文章:- 用vbs實現(xiàn)防止計算機使用 LMHosts 文件
- Windows Script Host之用vbs實現(xiàn)[瀏覽文件夾]功能
- 使用vbs刪除host文件域址內(nèi)容