通过vbs获取远程host文件并保存到指定目录

2023-12-01 0 511

复制代码 代码如下:
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

经测试,由于网络问题,可能获取会超时,建议大家多运行几次。或加入脚本可执行时间。

您可能感兴趣的文章:

  • vbs实现防止计算机使用 LMHosts 文件
  • Windows Script Host之用vbs实现[浏览文件夹]功能
  • 使用vbs删除host文件域址内容

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 VBS 通过vbs获取远程host文件并保存到指定目录 https://www.u-9.cn/jiaoben/vbscript/9316.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务