Download via URLDownloadToFile unreliable

Hi folks,
Users download an installer from my website, which runs VBA code to download zip files. The code uses the Windows API URLDownloadToFile.
The website is on Cloudflare and I made a page rule to cache everything in the folder where the zip files are located.
Installation works fine for me, but chokes for others globally, on the download of a zip file. Oddly, the download can work for one zip file but then not for the next one.
Any ideas? I need this to be reliable.
I did find this link: UrlDownloadToFile, Cloudflare, and IE8 - AutoHotkey Community
Is it really the case that URLDownloadToFile cannot be used? If not, what, that I can use from VBA?

Anything that isn’t a genuine browser is likely to run into challenge pages (which your installer can’t solve) or Bot Fight Mode.

What User-Agent is your installer using? You could make a firewall rule to allow that.

Thanks KianNH.
The user agent for one visitor who succeeded in downloading one zip file but not the next is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36
As reported by this VB function on my website:
Public Shared Function GetUserAgent() As String
Dim context = New HttpContextWrapper(HttpContext.Current)
Dim request As HttpRequestBase = context.Request
Dim browserdetail = request.UserAgent
If browserdetail IsNot Nothing Then
GetUserAgent = browserdetail
GetUserAgent = “Null User Agent”
End If
End Function
Or, are you suggesting that I set a user agent for URLDownloadToFile? How can that be done?
If that’s the problem, how come the first zip file downloads?
Is it possible that the zip file downloads are too close together? Would that trigger Bot Fight Mode?
I could add a delay. How long would that need to be?

If Bot Fight Mode or other checks like browser integrity are blocking it, you’ll see it in the firewall activity log.


Check in and see if that’s the case.

I don’t see anything there:

The user with the download problem was in Italy, so this is not them.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.