通过vbs获取远程host文件并保存到指定目录
程序员文章站
2024-01-02 16:22:10
复制代码 代码如下:
sub download(url,target)
const adtypebinary = 1
const adtypetext = 2
co...
复制代码 代码如下:
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
经测试,由于网络问题,可能获取会超时,建议大家多运行几次。或加入脚本可执行时间。