Download file via vbscript

October 6, 2012 at 09:46:05
Specs: Windows 7
Need to download a file with vbscript, none of the examples on the web have worked.
Can anyone provide a working example?

See More: Download file via vbscript

Report •

#1
October 6, 2012 at 10:13:59
none of the examples on the web . . .
Such as?

. . . have worked.
Why not?

How To Ask Questions The Smart Way


Report •

#2
October 6, 2012 at 10:16:45
lol razor.. and i was expecting a solution.
Search download file via vbscript on google, first 7 solutions do not work.
The rest following are generic or simply refer to the ones above.

Report •

#3
October 6, 2012 at 10:55:31
E.g with
strFileURL = "downloadlink"
strHDLocation = "C:\Users\xxxx\Downloads\beach2.flv"

' Fetch the file

Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")

objXMLHTTP.open "GET", strFileURL, 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(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing

objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if

Set objXMLHTTP = Nothing
I get the following:
Script: C:\Users\xxxx\Desktop\downloadfile.vbs
Line:9
Char:5
Error: The sysrem cannot locate the resource specific.
Code: 800C0005
Source:msxml3.dll


Report •

Related Solutions

#4
October 6, 2012 at 11:05:40
this one worked for me:
http://www.robvanderwoude.com/vbste...

(i simplified it to this for testing:)

'===== begin vbscript demonstrating a simple vbscript "wget" operation
set fso=createobject("scripting.filesystemobject")
set htp=createobject("winhttp.winhttprequest.5.1")
set ofile=fso.createtextfile("bat.jpg")
htp.open "GET","http://pages.suddenlink.net/kitpackers/lee/lee_files/batstik.jpg",false
htp.send
for i=1 to lenb(htp.responsebody)
ofile.write chr(ascb(midb(htp.responsebody,i,1)))
next
'==== end vbscript


Report •

#5
October 6, 2012 at 11:07:23
strFileURL = "downloadlink"
The site doesn't like this line. If the link is valid, the server is blocking the request. This isn't uncommon on sharing sites, largely to prevent what you're attempting. What's the site?

EDIT: Ick, nbrane, ADO.Stream is much easier to use.

How To Ask Questions The Smart Way


Report •

#6
October 6, 2012 at 11:20:48
yeah, I know. My vbscript knowledge is "slim-to-none" and my "help" documentation is also "slim-to-none", so I just threw that out there to show that it could work.

Report •

#7
October 6, 2012 at 11:34:06
@nbrane there are quite a few bugs on that when the dl is too big it has a problem with the strings. If it comes where i need it from, the download fails.
@Razor It wouldn't be appropriate to post the link, i just need a functioning script.
Won't urldownloadtofile be possible to implement here?

Report •

#8
October 6, 2012 at 11:39:35
The problem is the script is saying, "Hey, I want file 'downloadlink'," and the server's saying, "I have no idea what you're talking about." So if you can't share the site, it's up to you to determine what the blocking mechanism is, how to bypass it, and to modify the script appropriately.

How To Ask Questions The Smart Way


Report •

#9
October 6, 2012 at 11:55:08
lol fine, the site is theync.com.
Anyway, any video from there.

Report •

#10
October 6, 2012 at 12:14:27
Here's a direct link to one, http://www.media.theync.com/videos/...
Sorry for any crap i may have posted, for some reason i'm screwed up there today.

Report •

#11
October 7, 2012 at 12:38:04
What's strange is i am getting a response from the server(http debugger), getting a lot of response back. The size keeps on increasing so that isn't the problem, problem is the file is nowhere to be found.

Report •

#12
October 7, 2012 at 20:24:14
Try running it through wget, and I think you will see why. I tested it, and it went into an loop trying to download from "localhost". The probe is probably getting redirected to "127.0.0.1" port 80 ("localhost). Just my guess, but they're probably sending you a message to not try and "rip" their vids, Lol!

Report •

#13
October 8, 2012 at 06:01:25
Sorry forgot to include http://media.theync.com/videos/poor... is the correct link, anyway, i'll have to go with another language then.

Report •

#14
October 10, 2012 at 07:57:49
So the amount of time where I can look at questionable content has dwindled, so I haven't had much time to look at this. I looked at the link, and I noticed it redirects to a script page. I considered parsing the page, looking for the redirect link, but then I remembered was lazy, and just had IE handle it for me. This may or may not work for you, depending on your workflow.
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = true
IE.Navigate _
  "http://media.theync.com/videos/poor-baby-in-brazil-born-with-giant-arm.flv"

How To Ask Questions The Smart Way


Report •

#15
October 11, 2012 at 04:45:49
@Razor2.3
Appreciate you for trying but i'm trying to achieve something that will not require the user to corporate. The idea goal is to download it in the background.

Report •

Ask Question