IE脚本下载远程文件到本地开启

前提条件:

  1. 添加IE信任网站 
  2. 设定IE安全性【IE插件相关选项启用】
  3. 启用ADODB.Stream
    • 注册组件C:\Program Files\Common Files\System\ado\msado15.dll  
    • 修改注册表

      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{00000566-0000-0010-8000-00AA006D2EA4}]
      "Compatibility Flags"=dword:00000000

实例:

vbscript:

iLocal = "本地路径"
iRemote = "远程http路径"

set xPost = createobject("Microsoft.XMLHTTP")
xPost.Open "GET",iRemote,0
xPost.Send()
set sGet = createobject("ADODB.Stream")
sGet.Mode = 3
sGet.Type = 1
sGet.Open()
sGet.Write xPost.ResponseBody
sGet.SaveToFile iLocal,2

msgbox xPost.ResponseBody

set oShell = CreateObject("WScript.Shell")
oShell.run iLocal
set oShell = nothing

 

javascript:

var filepath = "本地路径";
var remotefile = "远程http路径";

var xPost = new ActiveXObject("Microsoft.XMLHTTP");
xPost.Open("GET",remotefile,false);
xPost.Send();

var sGet = new ActiveXObject("ADODB.Stream");
sGet.Type = 1;
sGet.Open();
sGet.Write(xPost.ResponseBody);
sGet.SaveToFile(filepath,2);
sGet.Close();
sGet=null;
xPost=null;

var oShell = new ActiveXObject("WScript.Shell");
oShell.run(filepath);

posted @ 2014-04-03 16:45  John29  阅读(221)  评论(0编辑  收藏  举报