Jump to content

Recommended Posts

Posted (edited)

Is there a way to downlod files via script, without the use of a thrid party app, and preferably without using the following:

Const adSaveCreateOverWrite = 2
saveToFile = False
msgbox "strUrl=" &strUrl &vbcrlf &"strSavetoFspec=" &strSavetoFspec
Dim oDnLod
set oDnLod = CreateObject("Msxml2.XmlHttp.3.0")
oDnLod.open "GET", strUrl, false
oDnLod.send()

If oDnLod.status = 200 Then

Dim oStream
set oStream = CreateObject("Adodb.Stream")
oStream.type = typeStream
oStream.open()
oStream.write(oDnLod.responseBody)

oStream.saveToFile strSavetoFspec , adSaveCreateOverWrite
oStream.close()
set oStream = nothing
saveToFile = True
else
Dim strNameTemp, i
i = InstrRev(strSavetoFspec, "\")
strNameTemp = mid(strSavetoFspec, i+1)
msgbox "while downloading " &strNameTemp & vbcrlf & oDnLod.statusText &vbtab &"status=" &oDnLod.status &vbcrlf &vbcrlf &vbcrlf &strUrl
End If

Using the Adodb.stream to save files is fine if you are getting small files but if they are larger 200mb+, one it will take forever, two it sucks up memory like an elephant at a water hole.

edit:

PS. if you want to test the above method do not hard code an EXE file as the file to download, most virusscanners will detect it as a virus. If it pulls the file from the commandline or an external file its fine.

Edited by IcemanND

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...