使用 VBS 下载文件 [英] Download a file with VBS
本文介绍了使用 VBS 下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 VBS 脚本,它生成一个 url 以从我网络上的服务器下载文件.我现在需要将文件下载到 "C:\rWallpaper\wallpaper.png"
,URL 存储在变量 "url"
中.
Ive got a VBS Script that,generates an url to download a file from a server on my network. I now need to download the file to "C:\rWallpaper\wallpaper.png"
, the URL is stored in the variable "url"
.
我喜欢它在 linux 上像 wget 一样工作,只需下载文件并将其保存到指定位置.
Id like it to work something like wget on linux, just download and save the file to a specified location.
推荐答案
您可以使用 XMLHTTP 下载并利用 ADO 流写入二进制数据;
You can download using XMLHTTP and leverage an ADO stream to write the binary data;
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", "http://example.com/someimage.png", False
xHttp.Send
with bStrm
.type = 1 '//binary
.open
.write xHttp.responseBody
.savetofile "c:\temp\someimage.png", 2 '//overwrite
end with
这篇关于使用 VBS 下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文