用js实现下载远程文件并保存在本地的脚本
时间:2021-08-10 09:25:36|栏目:JavaScript代码|点击: 次
//use: cscript this.js http://www.xxx.com/xxx.exe c:\xxx.exe
var objArgs = WScript.Arguments;
var sGet=new ActiveXObject("ADODB.Stream");
var xGet = false;
try {
xGet = new XMLHttpRequest();
}
catch (trymicrosoft) {
try {
xGet = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (othermicrosoft) {
try {
xGet = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
xGet = false;
}
}
}
xGet.Open ("GET",objArgs(0).toLowerCase(),0);
xGet.Send();
sGet.Mode=3;
sGet.Type=1;
sGet.Open();
sGet.Write (xGet.ResponseBody);
sGet.SaveToFile (objArgs(1).toLowerCase(),2);
var objArgs = WScript.Arguments;
var sGet=new ActiveXObject("ADODB.Stream");
var xGet = false;
try {
xGet = new XMLHttpRequest();
}
catch (trymicrosoft) {
try {
xGet = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (othermicrosoft) {
try {
xGet = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
xGet = false;
}
}
}
xGet.Open ("GET",objArgs(0).toLowerCase(),0);
xGet.Send();
sGet.Mode=3;
sGet.Type=1;
sGet.Open();
sGet.Write (xGet.ResponseBody);
sGet.SaveToFile (objArgs(1).toLowerCase(),2);
栏 目:JavaScript代码
下一篇:基于JavaScript代码实现兼容各浏览器的设为首页和加入收藏
本文标题:用js实现下载远程文件并保存在本地的脚本
本文地址:http://www.codeinn.net/misctech/165794.html