Downloads a file from the Internet.

Download URL, Filename 



Type: String

URL of the file to download. For example, might retrieve the welcome page for that organization.


Type: String

Specify the name of the file to be created locally, which is assumed to be in A_WorkingDir if an absolute path isn't specified. Any existing file will be overwritten by the new file.

Error Handling

An exception is thrown on failure.


This function downloads to a file. To download to a variable instead, see the example below. For alternative methods, see the following forum topic:

The download might appear to succeed even when the remote file doesn't exist. This is because many web servers send an error page instead of the missing file. This error page is what will be saved in place of Filename.

Firewalls or the presence of multiple network adapters may cause this function to fail. Also, some websites may block such downloads.

Caching: By default, the URL is retrieved directly from the remote server (that is, never from Internet Explorer's cache). To permit caching, precede the URL with *0 followed by a space; for example: *0 The zero following the asterisk may be replaced by any valid dwFlags number; for details, search for InternetOpenUrl.

Proxies: If a proxy server has been configured in Microsoft Internet Explorer's settings, it will be used.

FTP and Gopher URLS are also supported. For example:

Download "", "C:\My Folder\My"  ; Log in anonymously.
Download "", "C:\My Folder\My"  ; Log in as a specific user.
Download " Directory", "C:\Dir Listing.html"  ; Gets a directory listing in HTML format.


FileRead, FileCopy



Download "", "C:\AutoHotkey Latest Version.txt"
Download "", "C:\SomeOrg's"

#2: Download text to a variable:

whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "")
; Using 'true' above and the call below allows the script to remain responsive.
version := whr.ResponseText
MsgBox version

#3: Make an asynchronous HTTP request.

req := ComObjCreate("Msxml2.XMLHTTP")
; Open a request with async enabled."GET", "", true)
; Set our callback function.
req.onreadystatechange := Func("Ready")
; Send the request.  Ready() will be called when it's complete.
; If you're going to wait, there's no need for onreadystatechange.
; Setting async=true and waiting like this allows the script to remain
; responsive while the download is taking place, whereas async=false
; will make the script unresponsive.
while req.readyState != 4
    sleep 100

Ready() {
    global req
    if (req.readyState != 4)  ; Not done yet.
    if (req.status == 200) ; OK.
        MsgBox "Latest AutoHotkey version: " req.responseText
        MsgBox "Status " req.status,, 16