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

URLDownloadToFile Error -2147024891

1,888 views
Skip to first unread message

Chamitha

unread,
Apr 14, 2005, 5:19:34 PM4/14/05
to
The URLDownloadToFile API returns the status code -2147024891 when
attempting to download from a valid HTTP or FTP location. If the URL is
pasted into the browser the file is downloaded thus verifying the
correctness and accessability of the URL. Any idea of the cause of this
behavious?

Igor Tandetnik

unread,
Apr 14, 2005, 5:29:01 PM4/14/05
to
"Chamitha" <cham...@gmail.com> wrote in message
news:1113513574....@f14g2000cwb.googlegroups.com

The error is E_ACCESSDENIED. Are you, by any chance, calling
URLDownloadToFile from a service running under SYSTEM account?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Chamitha

unread,
Apr 14, 2005, 6:11:22 PM4/14/05
to
No. Its is being called in a simple VB 6.0 EXE.

Chamitha

unread,
Apr 14, 2005, 6:15:41 PM4/14/05
to
Sample

Dim RetCode As Long

RetCode = URLDownloadToFile(0,
"ftp://username:pass...@ftp.ftpurl.com/File.txt", "C:\Test\File.txt",
0, 0)

If Not (RetCode = 0) Then
MsgBox "Boom" 'The message box is displayed. RetCode = -2147024891
End If

Igor Tandetnik

unread,
Apr 14, 2005, 6:56:49 PM4/14/05
to
"Chamitha" <cham...@gmail.com> wrote in message
news:1113516941.9...@l41g2000cwc.googlegroups.com

> Sample
>
> Dim RetCode As Long
>
> RetCode = URLDownloadToFile(0,
> "ftp://username:pass...@ftp.ftpurl.com/File.txt", "C:\Test\File.txt",
> 0, 0)

Do you have rights to write to this file? In Explorer, can you create a
file in this directory?

Chamitha

unread,
Apr 15, 2005, 9:57:43 AM4/15/05
to
Yes.

Chamitha

unread,
Apr 15, 2005, 4:08:55 PM4/15/05
to
This issue only occurs on some PC's. Others work fine. Is there any
Service Pack or Patch which causes or elimiates this?

Chamitha

unread,
Apr 17, 2005, 6:18:33 PM4/17/05
to
Seems like the issue has something to do with a proxy.
URLDownloadToFile API executed on the same PC when connect to the
internet via a authenticated proxy server fails, but succeeds when
connected directly.
Any idea if the API can be used with a proxy server? If so are any
modifications required?

Igor Tandetnik

unread,
Apr 18, 2005, 11:13:32 AM4/18/05
to
"Chamitha" <cham...@gmail.com> wrote in message
news:1113776313.2...@l41g2000cwc.googlegroups.com

You should be able to create a COM object that implements
IBindStatusCallback and IAuthenticate, and pass it as the last
parameter. You can then supply user name and password via
IAuthenticate::Authenticate.

Another thing to try is InternetSetOption(NULL,
INTERNET_OPTION_PROXY_USERNAME) and INTERNET_OPTION_PROXY_PASSWORD. I'm
not sure if this works.

Viney Kumar

unread,
Jan 7, 2010, 5:53:11 PM1/7/10
to
Igor Tandetnik,

I am also getting error from UrlDownloadToFile(). But, my scenario and error
code are different. It fails when executed from behind proxy and under
SYSTEM account. It works fine if I either use direct connection or run under
a user account. I am making following call:

URLDownloadToFile(NULL, wszURL, wszFullpath, 0, NULL);

I have a service that runs under SYSTEM credentials. This service launches a
program, say, DownloadMyFile.exe that downloads a file using above call.
This download works.

Then I connect my machine to proxy and specify the proxy thru IE options.
After this URLDownloadToFile starts giving INET_E_RESOURCE_NOT_FOUND
(-2146697211) error.

Now when I double click on DownloadMyFile.exe, which makes it run under user
credentials, it successfully works, even from behind proxy.

I tried this on Vista/Win7/XP and found same behavior.

Any clues?

url:http://www.ureader.com/msg/151615.aspx

Igor Tandetnik

unread,
Jan 7, 2010, 6:11:13 PM1/7/10
to
Viney Kumar <kumar...@gmail.com> wrote:
> I am also getting error from UrlDownloadToFile(). But, my scenario
> and error code are different. It fails when executed from behind
> proxy and under
> SYSTEM account. It works fine if I either use direct connection or
> run under
> a user account. I am making following call:
>
> URLDownloadToFile(NULL, wszURL, wszFullpath, 0, NULL);
>
> I have a service that runs under SYSTEM credentials. This service
> launches a program, say, DownloadMyFile.exe that downloads a file
> using above call.
> This download works.
>
> Then I connect my machine to proxy and specify the proxy thru IE
> options.

You do this while IE is running under which account? My guess is, IE settings are per user so SYSTEM never sees your settings and doesn't know it's supposed to use a proxy.

0 new messages