2014-06-16 01:58:32

vbs文件下载小脚本

linux很方便可以直接wget,windows用vbs下载挺方便的。随便在网上找了个小脚本改了下就ok了。

命令行下执行参数url:cscript 1.vbs /url:http://www.baidu.com/img/bdlogo.gif

'执行后下载到当前目录:cscript 1.vbs /url:http://www.baidu.com/img/bdlogo.gif
Set xPost = CreateObject("Microsoft.XMLHTTP")
Set sGet = CreateObject("ADODB.Stream")
Sub DownloadToFile(url, file)
  xPost.Open "GET", url, False
  xPost.Send
  sGet.Type = 1
  sGet.Open
  sGet.Write xPost.responseBody
  sGet.SaveToFile file, 2
  sGet.Close
End Sub
dim url
url = WScript.Arguments.Named.Item("url")
dim fileName
fileName = Right(url, Len(url) - InStrRev(url,"/"))
DownloadToFile url, fileName

脚本抄自:VBS下载多个文件

发表回复