adodb – Windows脚本宿主(jscript):我如何下载二进制文件?
发布时间:2020-09-05 10:12:51 所属栏目:Windows 来源:互联网
导读:我正在尝试使用 Windows脚本宿主(JScript)自动下载文件.我看到ADODB.Stream有一个Open方法,其文档似乎应该可以打开HTTP URL并流式传输响应体: var url = http://example.com/example.tar.gz;var path = example.tar.gz;var input = WScript.CreateObject(
|
我正在尝试使用 Windows脚本宿主(JScript)自动下载文件.我看到ADODB.Stream有一个Open方法,其文档似乎应该可以打开HTTP URL并流式传输响应体: var url = 'http://example.com/example.tar.gz';
var path = 'example.tar.gz';
var input = WScript.CreateObject('ADODB.Stream');
input.Open(url);
input.SaveToFile(path);
input.Close();
但它在公开电话上遭到轰炸 (null):在此操作的范围内未找到与名称,范围或选择条件匹配的对象或数据. 这是JScript中的下载代码.还添加了一些API信息的引用.var Source = WScript.Arguments.Item(0);
var Target = WScript.Arguments.Item(1);
var Object = WScript.CreateObject('MSXML2.XMLHTTP');
Object.Open('GET',Source,false);
Object.Send();
if (Object.Status == 200)
{
// Create the Data Stream
var Stream = WScript.CreateObject('ADODB.Stream');
// Establish the Stream
Stream.Open();
Stream.Type = 1; // adTypeBinary
Stream.Write(Object.ResponseBody);
Stream.Position = 0;
// Create an Empty Target File
var File = WScript.CreateObject('Scripting.FileSystemObject');
if (File.FileExists(Target))
{
File.DeleteFile(Target);
}
// Write the Data Stream to the File
Stream.SaveToFile(Target,2); // adSaveCreateOverWrite
Stream.Close();
}
ADODB流: > http://www.w3schools.com/ado/ado_ref_stream.asp Scripting.FileSystemObject的: > http://www.w3schools.com/asp/asp_ref_filesystem.asp (编辑:十堰站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 以MONO Runtime为目标导致Xamarin Build失败
- 如何在Windows 8.1上安装PyBluez?
- windows – CFileDialog :: OnInitDialog()不调用
- windows – sysopen权限被拒绝
- windows10 安装python.msi出现error 2502/2503解决方法
- 如何在Windows Phone 7系列上获取屏幕尺寸?
- .net – 在Windows应用程序中格式化标签内的文本
- 如何使用GUI独立于.NET或其他Libs为Windows制作便携式C程序
- 在WPF中的所有Windows中应用按钮样式
- 找出占用Installer 目录空间的元凶
推荐文章
站长推荐
- windows-phone-7 – 多长时间调用SpriteBatch.Be
- winforms – .NET ListView和Windows 7
- Microsoft Unit Testing Framework for C++
- 深度技术 Win11 64位全新系统下载
- 如何正确使用MSBuild社区任务库在.NET dll上设置
- windows – 带双引号参数的exec
- windows-8 – 在MetroStyle应用程序中使用COM对象
- windows-phone-7 – 如何将SystemTray Progressb
- windows-ce – 确定Windows CE可执行文件使用的1
- windows-phone-8 – 启动TaskHost.exe失败,尝试运
热点阅读
