<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: VBScript: Download and Save a Binary File</title>
	<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/</link>
	<description>ls /usr/lolcat</description>
	<pubDate>Wed, 07 Jan 2009 10:16:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Chris</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10546</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sun, 04 Jan 2009 21:01:09 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10546</guid>
		<description>Fantastic script, just does what I need.

By the way, virus alert can be avoided if "Microsoft.XmlHttp" is used instead of "MSXML2.XMLHTTP".

Thank you very much!</description>
		<content:encoded><![CDATA[<p>Fantastic script, just does what I need.</p>
<p>By the way, virus alert can be avoided if "Microsoft.XmlHttp" is used instead of "MSXML2.XMLHTTP".</p>
<p>Thank you very much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruce</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10520</link>
		<dc:creator>Bruce</dc:creator>
		<pubDate>Wed, 24 Dec 2008 06:03:17 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10520</guid>
		<description>Beautiful - thank you very much.</description>
		<content:encoded><![CDATA[<p>Beautiful - thank you very much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Otoman</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10498</link>
		<dc:creator>Otoman</dc:creator>
		<pubDate>Fri, 12 Dec 2008 23:52:00 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10498</guid>
		<description>Can we download a file form Website with BAtch file. without using external command or Functions
Thankx</description>
		<content:encoded><![CDATA[<p>Can we download a file form Website with BAtch file. without using external command or Functions<br />
Thankx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10482</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 02 Dec 2008 06:16:56 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10482</guid>
		<description>Perfect, just what I was looking for.</description>
		<content:encoded><![CDATA[<p>Perfect, just what I was looking for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: quux</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10456</link>
		<dc:creator>quux</dc:creator>
		<pubDate>Fri, 07 Nov 2008 11:38:27 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10456</guid>
		<description>Something's up with WP. When I try to post a link to a better-formatted version of the script above, I get redirected to a blank page. Sorry if I just dumped like 20 bogus posts into your approval queue (if you have one).</description>
		<content:encoded><![CDATA[<p>Something's up with WP. When I try to post a link to a better-formatted version of the script above, I get redirected to a blank page. Sorry if I just dumped like 20 bogus posts into your approval queue (if you have one).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: quux</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10455</link>
		<dc:creator>quux</dc:creator>
		<pubDate>Fri, 07 Nov 2008 11:16:36 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10455</guid>
		<description>Hi there,

Nice script - thanks!

I've refactored it a bit so that it can be called as a simple function which downloads directly to your temp dir. So now you can:

Call DownloadFile("http://imgs.xkcd.com/comics/faust_20.png")

And it will download that file to your temp dir. Here is the function:

Function DownloadFile(DownloadUrl) 'generic file downloader, saves to temp
'Get name of file from url (whatever follows the final forwardslash "/")
Dim arURL, FileName, FileSaveLocation
arURL = Split(DownloadUrl,"/",-1,1)
If arURL(UBound(arURL)) = "" Then 'if there is a trailing forwardslash
	FileName = arURL(UBound(arURL) -1)
Else
	filename = arURL(UBound(arURL))
End If
'Get temp folder location
Dim oFS, TempDir
Set oFS = CreateObject("Scripting.FileSystemObject")
Set TempDir = oFS.getSpecialFolder(2) 
Wscript.Echo TempDir &#38; "\" &#38; FileName
FileSaveLocation = TempDir &#38; "\" &#38; FileName

' Fetch the file
Dim oXMLHTTP, oADOStream
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oXMLHTTP.open "GET", DownloadUrl, false
oXMLHTTP.send()
If oXMLHTTP.Status = 200 Then
	Set oADOStream = CreateObject("ADODB.Stream")
	oADOStream.Open
	oADOStream.Type = 1 'adTypeBinary	
	oADOStream.Write oXMLHTTP.ResponseBody
	oADOStream.Position = 0    'Set the stream position to the start
	If oFS.Fileexists(FileSaveLocation) Then oFS.DeleteFile FileSaveLocation
	Set oFS = Nothing
	oADOStream.SaveToFile FileSaveLocation
	oADOStream.Close
	Set oADOStream = Nothing
End if
Set oXMLHTTP = Nothing
End Function</description>
		<content:encoded><![CDATA[<p>Hi there,</p>
<p>Nice script - thanks!</p>
<p>I've refactored it a bit so that it can be called as a simple function which downloads directly to your temp dir. So now you can:</p>
<p>Call DownloadFile("http://imgs.xkcd.com/comics/faust_20.png")</p>
<p>And it will download that file to your temp dir. Here is the function:</p>
<p>Function DownloadFile(DownloadUrl) 'generic file downloader, saves to temp<br />
'Get name of file from url (whatever follows the final forwardslash "/")<br />
Dim arURL, FileName, FileSaveLocation<br />
arURL = Split(DownloadUrl,"/",-1,1)<br />
If arURL(UBound(arURL)) = "" Then 'if there is a trailing forwardslash<br />
	FileName = arURL(UBound(arURL) -1)<br />
Else<br />
	filename = arURL(UBound(arURL))<br />
End If<br />
'Get temp folder location<br />
Dim oFS, TempDir<br />
Set oFS = CreateObject("Scripting.FileSystemObject")<br />
Set TempDir = oFS.getSpecialFolder(2)<br />
Wscript.Echo TempDir &amp; "\" &amp; FileName<br />
FileSaveLocation = TempDir &amp; "\" &amp; FileName</p>
<p>' Fetch the file<br />
Dim oXMLHTTP, oADOStream<br />
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")<br />
oXMLHTTP.open "GET", DownloadUrl, false<br />
oXMLHTTP.send()<br />
If oXMLHTTP.Status = 200 Then<br />
	Set oADOStream = CreateObject("ADODB.Stream")<br />
	oADOStream.Open<br />
	oADOStream.Type = 1 'adTypeBinary<br />
	oADOStream.Write oXMLHTTP.ResponseBody<br />
	oADOStream.Position = 0    'Set the stream position to the start<br />
	If oFS.Fileexists(FileSaveLocation) Then oFS.DeleteFile FileSaveLocation<br />
	Set oFS = Nothing<br />
	oADOStream.SaveToFile FileSaveLocation<br />
	oADOStream.Close<br />
	Set oADOStream = Nothing<br />
End if<br />
Set oXMLHTTP = Nothing<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chrissy</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10447</link>
		<dc:creator>Chrissy</dc:creator>
		<pubDate>Wed, 29 Oct 2008 03:58:58 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10447</guid>
		<description>It's not a virus nor does it contain a virus. A lot of anti virus apps wrongly consider any vbs file a virus. Or maybe it hates FSO. But you can see clearly from the code that it's just downloading a file. If that's a virus, then I download hundreds of viruses a day.</description>
		<content:encoded><![CDATA[<p>It's not a virus nor does it contain a virus. A lot of anti virus apps wrongly consider any vbs file a virus. Or maybe it hates FSO. But you can see clearly from the code that it's just downloading a file. If that's a virus, then I download hundreds of viruses a day.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kei</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10446</link>
		<dc:creator>Kei</dc:creator>
		<pubDate>Tue, 28 Oct 2008 13:30:25 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10446</guid>
		<description>Thats is so POSSIBLE IMPOSSIBLE!
The text contains VIRUS! Holy moly once i saved as a text the avast pop up and says that it contain virus even that it just a TEXT VBS.</description>
		<content:encoded><![CDATA[<p>Thats is so POSSIBLE IMPOSSIBLE!<br />
The text contains VIRUS! Holy moly once i saved as a text the avast pop up and says that it contain virus even that it just a TEXT VBS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10413</link>
		<dc:creator>Amit</dc:creator>
		<pubDate>Mon, 29 Sep 2008 20:58:52 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10413</guid>
		<description>I have just tested your script and it worked well with small size of file but in case of large file say 500MB it throws following error:
ADODB.Stream: Out of memory

Please fix the code and let us know.

Thank you very much.</description>
		<content:encoded><![CDATA[<p>I have just tested your script and it worked well with small size of file but in case of large file say 500MB it throws following error:<br />
ADODB.Stream: Out of memory</p>
<p>Please fix the code and let us know.</p>
<p>Thank you very much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit</title>
		<link>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10412</link>
		<dc:creator>Amit</dc:creator>
		<pubDate>Mon, 29 Sep 2008 20:35:27 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/#comment-10412</guid>
		<description>Thanks for providing this script, it really helped me a lot.</description>
		<content:encoded><![CDATA[<p>Thanks for providing this script, it really helped me a lot.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
