Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

wget.vbs - similar to wget but written in vbscript

View wget.vbs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
'wget.vbs - similar to wget but written in vbscript
'based on a script by Chrissy LeMaire
 
' Usage
if WScript.Arguments.Count < 1 then
MsgBox "Usage: wget.vbs <url> (file)"
WScript.Quit
end if
 
' Arguments
URL = WScript.Arguments(0)
if WScript.Arguments.Count > 1 then
saveTo = WScript.Arguments(1)
else
parts = split(url,"/")
saveTo = parts(ubound(parts))
end if
 
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
 
objXMLHTTP.open "GET", URL, false
objXMLHTTP.send()
 
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
 
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
 
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(saveTo) Then objFSO.DeleteFile saveTo
Set objFSO = Nothing
 
objADOStream.SaveToFile saveTo
objADOStream.Close
Set objADOStream = Nothing
End if
 
Set objXMLHTTP = Nothing
 
' Done
WScript.Quit

MSXML2.ServerXMLHTTP can be used in place of MSXML2.XMLHTTP if you encounter "Access is denied" errors.

Owner

@MalikKillian
Thanks. Your comment is very useful to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.