Last active
October 2, 2018 16:16
-
-
Save ninp0/5a44d68116b39cae026d269d6ab61d2f to your computer and use it in GitHub Desktop.
This file contains 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
'Usage: cscript wget.vbs <target_url> <filename_to_save_as> | |
strUrl = WScript.Arguments.Item(0) | |
StrFile = WScript.Arguments.Item(1) | |
Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0 | |
Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0 | |
Const HTTPREQUEST_PROXYSETTING_DIRECT = 1 | |
Const HTTPREQUEST_PROXYSETTING_PROXY = 2 | |
Dim http, varByteArray, strData, strBuffer, lngCounter, fs, ts | |
Set http = Nothing | |
Set http = CreateObject("WinHttp.WinHttpRequest.5.1") | |
If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest") | |
If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP") | |
If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP") | |
http.Open "GET", strURL, False | |
http.Send | |
varByteArray = http.ResponseBody | |
Set http = Nothing | |
Set fs = CreateObject("Scripting.FileSystemObject") | |
Set ts = fs.CreateTextFile(StrFile, True) | |
strData = "" | |
strBuffer = "" | |
For lngCounter = 0 to UBound(varByteArray) | |
ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1))) | |
Next | |
ts.Close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment