Skip to content

Instantly share code, notes, and snippets.

@caglarorhan
Created January 25, 2018 18:17
Show Gist options
  • Save caglarorhan/44f7ebcc857f0c1be1aff2cc13349c23 to your computer and use it in GitHub Desktop.
Save caglarorhan/44f7ebcc857f0c1be1aff2cc13349c23 to your computer and use it in GitHub Desktop.
Downloading a file from url with XMLHTTP and ADODB.Stream in VBScript
cURL = InputBox("Write a full url of file to be downloaded!")
If cURL<>"" Then
Dim strDIR
strDIR = WScript.ScriptFullName
strDIR = Left(strDIR,InStrRev(strDIR,"\"))
Dim strFIL
strFIL = Mid(cURL,InStrRev(cURL,"/")+1)
Dim objADO
Set objADO = CreateObject("ADODB.Stream")
Dim objXML
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", cURL, False
objXML.Send
If Err.Number = 0 And objXML.Status = 200 Then
objADO.Type = 1
objADO.Open
objADO.Write objXML.ResponseBody
objADO.SaveToFile strDIR & strFIL,2
booMSG = True
End If
Set objADO = Nothing
Set objXML = Nothing
End if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment