Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

retrieve downloaded filename from redirected URL

1 view
Skip to first unread message

pau...@gmail.com

unread,
Dec 6, 2005, 1:15:41 PM12/6/05
to
For example: http://go.microsoft.com/fwlink/?LinkId=42542. When put
into a browser, the browser prompts if you want to save
"WindowsInstaller-KB893803-v2-x86.exe" to disk. Is there any way to
retrieve this filename (or better yet, URL) via
MSXML2.ServerXMLHTTP.3.0 or by some other means?

Im trying to download the file given the above URL, but I do not want
to assume the file is .exe and give it a filename I choose. I want to
use the original name of the file.

Heres a code snippet:

DownloadFile "http://go.microsoft.com/fwlink/?LinkId=42542",
"c:\file.exe"

Sub DownloadFile(URL, myFileName)
Const adTypeBinary = 1
Const adSaveCreateOverwrite = 2
Dim oHTTP, oStream

Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0")
oHTTP.Open "GET", URL, False
oHTTP.Send
Set oStream = CreateObject("ADODB.Stream")
oStream.Type = adTypeBinary
oStream.Open
oStream.Write oHTTP.ResponseBody
'###################################################################
' instead of using myFileName, I'd like to use the default name of
the file
' (WindowsInstaller-KB893803-v2-x86.exe in this case)
oStream.Savetofile myFileName, adSaveCreateOverwrite
'###################################################################
oStream.Close
End Sub

Any help would be appreciated. Thx

McKirahan

unread,
Dec 6, 2005, 6:24:50 PM12/6/05
to
<pau...@gmail.com> wrote in message
news:1133892941.6...@g43g2000cwa.googlegroups.com...

> For example: http://go.microsoft.com/fwlink/?LinkId=42542. When put
> into a browser, the browser prompts if you want to save
> "WindowsInstaller-KB893803-v2-x86.exe" to disk. Is there any way to
> retrieve this filename (or better yet, URL) via
> MSXML2.ServerXMLHTTP.3.0 or by some other means?
>
> Im trying to download the file given the above URL, but I do not want
> to assume the file is .exe and give it a filename I choose. I want to
> use the original name of the file.
>
> Heres a code snippet:
>
> DownloadFile "http://go.microsoft.com/fwlink/?LinkId=42542",
> "c:\file.exe"

[snip]

Sorry, nothing below helps.


Unfortunately, the URL's "HEAD" data doesn't contain the filename:

Content-Length: 2585872
Content-Type: application/octet-stream
Last-Modified: Wed, 04 May 2005 22:24:18 GMT
Accept-Ranges: bytes
ETag: "4c43443f850c51:8037"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 06 Dec 2005 20:06:01 GMT
Connection: keep-alive


Both URLs below may download the same file

<URL:http://go.microsoft.com/fwlink/?LinkId=42542>

<URL:http://download.microsoft.com/download/1/4/7/147ded26-931c-4daf-9095-ec
7baf996f46/WindowsInstaller-KB893803-v2-x86.exe>


If the latter were used the filename could be extracted from the URL:

Const cURL = "http://www.microsoft.com/downloads/info.aspx?...
.../WindowsInstaller-KB893803-v2-x86.exe
Dim strFIL
strFIL = Mid(cURL,InStr(cURL,"/")+1)


Microsoft obfuscates the filename via the LinkId.
I could find nothing that would offer any insight.

pau...@gmail.com

unread,
Dec 7, 2005, 12:00:26 PM12/7/05
to
:( Thanks for the help.

pau...@gmail.com

unread,
Dec 7, 2005, 12:05:22 PM12/7/05
to
Actually, may I ask how you got the URL -
http://download.microsoft.com/download/1/4/7/147ded26-931c-4daf-9095-ec

7baf996f46/WindowsInstaller-KB893803-v2-x86.exe ? If theres a way to
get the URL in this format from the forwarding link (
http://go.microsoft.com/fwlink/?LinkId=42542 ) I could use that just
fine.

McKirahan

unread,
Dec 7, 2005, 12:27:34 PM12/7/05
to
<pau...@gmail.com> wrote in message
news:1133975122.1...@f14g2000cwb.googlegroups.com...

A search of
http://www.microsoft.com/

for
WindowsInstaller-KB893803-v2-x86.exe

gave this link

URL:http://www.microsoft.com/downloads/details.aspx?FamilyID=889482fc-5f56-4
a38-b838-de776fd4138c&displaylang=en

which listed the file under
Files in This Download

whose URL was

URL:http://www.microsoft.com/downloads/info.aspx?na=208&p=3&SrcDisplayLang=e
n&SrcCategoryId=&SrcFamilyId=889482fc-5f56-4a38-b838-de776fd4138c&u=http%3a%
2f%2fdownload.microsoft.com%2fdownload%2f1%2f4%2f7%2f147ded26-931c-4daf-9095
-ec7baf996f46%2fWindowsInstaller-KB893803-v2-x86.exe

from which I extracted

URL:http://download.microsoft.com/download/1/4/7/147ded26-931c-4daf-9095-ec7
baf996f46/WindowsInstaller-KB893803-v2-x86.exe

after converting "%3a" to ":" and each "%2f" to "/"


0 new messages