Skip to content

Instantly share code, notes, and snippets.

@richardcurteis
Forked from udawtr/wget.vbs
Created August 21, 2019 22:10
Show Gist options
  • Save richardcurteis/1455b265f5a75d3172816b415d698817 to your computer and use it in GitHub Desktop.
Save richardcurteis/1455b265f5a75d3172816b415d698817 to your computer and use it in GitHub Desktop.

Revisions

  1. @udawtr udawtr revised this gist Nov 28, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wget.vbs
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ else
    end if

    ' Fetch the file
    Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
    Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")

    objXMLHTTP.open "GET", URL, false
    objXMLHTTP.send()
  2. @udawtr udawtr created this gist Mar 16, 2012.
    45 changes: 45 additions & 0 deletions wget.vbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,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.XMLHTTP")

    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