通過vbs獲取遠(yuǎn)程host文件并保存到指定目錄
更新時間:2014年12月17日 23:04:59 投稿:mdxy-dxy
最近需要訪問google聯(lián)盟后臺,但經(jīng)常無法訪問,看到有網(wǎng)友提供了一份vbs版本的獲取host并保存到指定目錄的代碼,特分享下
復(fù)制代碼 代碼如下:
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í)行時間。
相關(guān)文章
VBS教程:函數(shù)-LTrim、RTrim 和 Trim 函數(shù)
VBS教程:函數(shù)-LTrim、RTrim 和 Trim 函數(shù)...2006-11-11vbscript和javascript版的15位, 18位的身份證號碼的驗證函數(shù).以及根據(jù)身份證取省份,生日,
vbscript和javascript版的15位, 18位的身份證號碼的驗證函數(shù).以及根據(jù)身份證取省份,生日,性別2007-04-04