找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 17199|回复: 2

[原创] VBS自动下载hosts,上google 网站必备

[复制链接]
发表于 2013-5-27 17:05:55 | 显示全部楼层 |阅读模式
  1. Sub download(url,target)
  2.         Const adTypeBinary = 1
  3.         Const adTypeText = 2
  4.         Const adSaveCreateOverWrite = 2
  5.         Dim http,ado
  6.         Set http = CreateObject("Msxml2.ServerXMLHTTP")
  7.         http.SetOption 2,13056
  8.         http.open "GET",url,False
  9.         http.send
  10.         Set ado = createobject("Adodb.Stream")
  11.         ado.Type = adTypeBinary
  12.         ado.Open
  13.         ado.Write http.responseBody
  14.         ado.SaveToFile target,adSaveCreateOverWrite
  15.         ado.Close
  16. End Sub
  17. Set WshShell=CreateObject("WScript.Shell")
  18. WinDir =WshShell.ExpandEnvironmentStrings("%WinDir%")
  19. HostsFile = WinDir & "\System32\Drivers\etc\Hosts"
  20. Const hosts="https://smarthosts.googlecode.com/svn/trunk/hosts"
  21. download hosts,HostsFile
复制代码

评分

参与人数 1技术 +1 收起 理由
CrLf + 1 谢谢分享!

查看全部评分

发表于 2013-5-27 17:25:38 | 显示全部楼层
看起来很实用的样子,收藏了,谢谢分享
发表于 2013-6-19 14:37:37 | 显示全部楼层
好东西啊,还准备自己写个呢,现在可以直接用了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-16 23:15 , Processed in 0.018462 second(s), 9 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表