开发者

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

复制代码 代码如下:

Sub do编程客栈wnload(url,target)

Const adTypeBinary = 1

Const adTyp开发者_JAVA学习eText = 2

Const adSaveCreateOverWrite = 2

Dim http,ado

Set http = CreateObject("Msxml2.Se编程客栈rverXMLHTTP")

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=CreateOb编程客栈ject("WScript.Shell")

WinDir =WshShell.ExpandEnvironmentStrings("%WinDir%")

HostsFi编程客栈le = WinDir & "\System32\Drivers\etc\Hosts_google"

Const hosts="https://raw.githubusercontent.com/vokins/simpleu/master/hosts"

download hosts,HostsF编程客栈ile

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新开发

开发排行榜