Created
June 20, 2013 09:42
-
-
Save duncansmart/5821523 to your computer and use it in GitHub Desktop.
Download a file with Windows Script Host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// httpget.js: download a file (Windows Script Host) | |
// usage: cscript httpget.js <url> <file> | |
(function() { | |
if (WScript.Arguments.Length != 2) { | |
WScript.Echo("Usage: httpget.js <url> <file>") | |
WScript.Quit(1) | |
} | |
var url = WScript.Arguments(0) | |
var filepath = WScript.Arguments(1) | |
var xhr = new ActiveXObject("MSXML2.XMLHTTP") | |
xhr.open("GET", url, false) | |
xhr.send() | |
if (xhr.Status == 200) { | |
var fso = new ActiveXObject("Scripting.FileSystemObject") | |
if (fso.FileExists(filepath)) | |
fso.DeleteFile(filepath) | |
var stream = new ActiveXObject("ADODB.Stream") | |
stream.Open() | |
stream.Type = 1 //adTypeBinary | |
stream.Write(xhr.ResponseBody) | |
stream.Position = 0 | |
stream.SaveToFile(filepath) | |
stream.Close() | |
} | |
else { | |
WScript.Echo("Error: HTTP " + xhr.status + " "+ xhr.statusText) | |
} | |
})(); |
ممكن معلومات عن كود
When I try to run it, it shows an error "Access is denied"
When I try to run it, it shows an error "Access is denied"
yes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
harrisdekker)
CreateObject("Wscript.Shell").Run('C:\cock.exe', 0, False)