Home >Web Front-end >JS Tutorial >Use js to implement a script that downloads remote files and saves them locally_javascript skills

Use js to implement a script that downloads remote files and saves them locally_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:04:551696browse

//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);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn