命令行使用vbscript下载大文件(500 + mb) [英] Command line download large (500+mb) file using vbscript

查看:56
本文介绍了命令行使用vbscript下载大文件(500 + mb)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题的核心:我正在尝试使用VBScript下载650mb的文件。任何超过500mb的文件都会失败,并显示以下错误...

Heart of the problem: I'm trying to download a 650mb file using VBScript. Any file over 500mb fails with the following error...

错误:没有足够的存储空间来完成此操作
代码: 8007000E

来源:msxml3.dll <-使用MSXML.XMLHTTP时或...

Source: msxml3.dll <-- When using MSXML.XMLHTTP or...

来源:WinHttp.WinHttpRequest <-使用WinHTTP时

Source: WinHttp.WinHttpRequest <-- when using WinHTTP

我正在从此处使用代码 ,即MSXML.XMLHTTP和WinHTTP(不是wget)。我可以在任务管理器中观看的两个脚本的大小都刚好超过650mb,然后由于上述错误而失败。脚本可以正常工作,如果我选择较小的文件,下载就很好了。

I'm using the code from here, both MSXML.XMLHTTP and WinHTTP (not wget). Both scripts I can watch in Task Manager build up to just over 650mb, and then fail with the above error. The scripts work, if I choose smaller files the download occurs just fine.

错误消息中引用的行是。写objHTTP.responseBody

The lines referenced in the error messages is .Write objHTTP.responseBody for both.

我发现其他一些人也有同样的问题,尽管似乎没有很多人试图用vbscript下载巨型文件...我无法想象为什么。

I've found a few other people having this same problem, although there doesn't seem to be a large amount of people trying to download giant files with vbscript... I can't imagine why.

我知道这不是空间问题(我有足够的硬盘空间),或者内存问题(我有4GB,物理内存显示大约为70%)。在使用WinHTTP时,我还尝试在此处中将SetTimeouts选项设置为详细(我什至将它们全部设置为-1(无限超时),并尝试使用MSXML.ServerXMLHTTP(它也允许SetTimeouts),这两个步骤都是不可行的

I know it's not a space issue (I have plenty of hard drive space), or a memory issue (I have 4gb, physical memory shows about 70% at peak). I've also tried setting the SetTimeouts option as detailed here when using WinHTTP (I even set them all to -1, infinite timeout), and tried using MSXML.ServerXMLHTTP which allows SetTimeouts as well, both a no-go

背景:
我正在尝试编写vbscript,以自动为大量用户下载并安装一套软件。因为它将要分发给这么多的人,所以我想在Windows中本地进行,因为我不确切知道他们可能拥有或可能没有的其他软件。这极大地限制了我的选择。 Powershell政策已设置为受限政策,因此我不能在其他计算机上使用该政策,除非不详细说明如何为其他计算机重置政策,这违背了脚本的目的,该脚本本应为非技术人员执行所有操作。这几乎留下了vbscript。

Background: I'm trying to write a vbscript to automatically download and install a set of software for a large number of users. Because it's going to be distributed to so many people I would like to do it natively in Windows, since I don't know exactly what other software they may or may not have. This limits my options quite a bit. Powershell policy is set to restricted, so I can't use that on others computers, not without detailing how to reset it for them which defeats the purpose of a script that's supposed to do everything for non-techie users. This pretty much leaves vbscript.

如果没有其他方法可以完成,那么我的下一步可能是自动化下载和安装较小的文件(如wget),然后用它来下载较大的一个。再说一次,我想用最少的本地软件来做到这一点。似乎这应该可行,但是我找不到解决方法。

If there is no other way to do this, then my next step is probably going to be to automate the downloading and installation of a smaller file, like wget, and then use that to download the larger one. Again though, I'd like to do this with minimum, native software. It seems like this is something that should be possible, but I can't find a solution.

编辑:作为新用户,我不能发布2个以上的链接,因此您只需要相信我,我发现其他人也遇到了这个问题,但是他们的线程(在这里或其他地方)没有答案。

edit: I can't post more than 2 links as a new user, so you're just going to have to take my word that I've found other people having this issue, but no answers to their threads (here or anywhere else).

推荐答案

我无法重现您的问题,因此无法提供解决方案。但是,您可以通过分块而不是整体下载文件来解决该问题:

I cannot reproduce your problem, so I'm unable to provide a solution. However, you may be able to work around it by downloading the file in chunks instead of as a whole:

chunksize = 524288000  '500 MB
url = "..."

Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1 'binary

i = 0
Do
  first = i * chunksize
  last  = first + chunksize - 1

  Set req = CreateObject("Msxml2.XMLHttp.6.0")
  req.open "GET", url, False
  req.setRequestHeader "Range", "bytes=" & first & "-" & last
  req.send

  If req.Status = 206 Then stream.Write req.responseBody

  i = i + 1
Loop Until CLng(req.getResponseHeader("Content-Length")) <> chunksize

stream.SaveToFile "C:\path\to\output.file", 2
stream.Close

这篇关于命令行使用vbscript下载大文件(500 + mb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆