Displays a standard dialog that allows the user to select a folder.

SelectedFolder := DirSelect(StartingFolder, Options, Prompt)



Type: String

If blank or omitted, the dialog's initial selection will be the user's My Documents folder (or possibly My Computer). A CLSID folder such as "::{20d04fe0-3aea-1069-a2d8-08002b30309d}" (i.e. My Computer) may be specified start navigation at a specific special folder.

Otherwise, the most common usage of this parameter is an asterisk followed immediately by the absolute path of the drive or folder to be initially selected. For example, "*C:\" would initially select the C drive. Similarly, "*C:\My Folder" would initially select that particular folder.

The asterisk indicates that the user is permitted to navigate upward (closer to the root) from the starting folder. Without the asterisk, the user would be forced to select a folder inside StartingFolder (or StartingFolder itself). One benefit of omitting the asterisk is that StartingFolder is initially shown in a tree-expanded state, which may save the user from having to click the first plus sign.

If the asterisk is present, upward navigation may optionally be restricted to a folder other than Desktop. This is done by preceding the asterisk with the absolute path of the uppermost folder followed by exactly one space or tab. For example, "C:\My Folder *C:\My Folder\Projects" would not allow the user to navigate any higher than C:\My Folder (but the initial selection would be C:\My Folder\Projects).


Type: Integer

One of the following numbers:

0: The options below are all disabled (except on Windows 2000, where the "make new folder" button might appear anyway).

1 (default): A button is provided that allows the user to create new folders.

Add 2 to the above number to provide an edit field that allows the user to type the name of a folder. For example, a value of 3 for this parameter provides both an edit field and a "make new folder" button.

Add 4 to the above number to omit the BIF_NEWDIALOGSTYLE property. Adding 4 ensures that DirSelect will work properly even in a Preinstallation Environment like WinPE or BartPE. However, this prevents the appearance of a "make new folder" button.

If the user types an invalid folder name in the edit field, SelectedFolder will be set to the folder selected in the navigation tree rather than what the user entered.


Type: String

Text displayed in the window to instruct the user what to do. If omitted or blank, it will default to "Select Folder - " A_ScriptName (i.e. the name of the current script).

Return Value

Type: String

This function returns the full path and name of the folder chosen by the user. If the user cancels the dialog (i.e. does not wish to select a folder), an empty string is returned. If the user selects a root directory (such as C:\), the return value will contain a trailing backslash. If this is undesirable, remove it as follows:

Folder := RegExReplace(DirSelect(), "\\$")  ; Removes the trailing backslash, if present.

An empty string is also returned if the system refused to show the dialog, but this is very rare.


A folder-selection dialog usually looks like this:


A GUI window may display a modal folder-selection dialog by means of the +OwnDialogs option. A modal dialog prevents the user from interacting with the GUI window until the dialog is dismissed.

Known limitation: A timer that launches during the display of a DirSelect dialog will postpone the effect of the user's clicks inside the dialog until after the timer finishes. To work around this, avoid using timers whose subroutines take a long time to finish, or disable all timers during the dialog:

Thread "NoTimers"
SelectedFolder := DirSelect(, 3)
Thread "NoTimers", false

FileSelect, MsgBox, InputBox, ToolTip, GUI, CLSID List, DirCopy, DirMove, SplitPath

Also, the operating system offers standard dialog boxes that prompt the user to pick a font, color, or icon. These dialogs can be displayed via DllCall as demonstrated at GitHub.


Allows the user to select a folder and provides both an edit field and a "make new folder" button.

SelectedFolder := DirSelect(, 3)
if SelectedFolder = ""
    MsgBox "You didn't select a folder."
    MsgBox "You selected folder '" SelectedFolder "'."

A CLSID example. Allows the user to select a folder in the "My Computer" directory.

SelectedFolder := DirSelect("::{20d04fe0-3aea-1069-a2d8-08002b30309d}")  ; My Computer.