Windows Installer, Java Installer, Freeware Installer
Home|Contact|Site Map|TOC|Search
Download  Features   Java  Licensing  Purchase  Testimonials  Support  Forums

How to browse for a folder at install time?

Answer

It might be required to allow the user to select a second folder during the installation, in addition to the Application Folder. In order to achieve this you would need to implement the functionality provided by the predefined FolderDlg dialog, as described below.

Download and unzip the Browse For Folder example project to better understand how to configure your own package. An Enterprise version of Advanced Installer (version 5.0 or greater) is required in order to build and run the project. However, you can use any Enterprise version of Advanced Installer greater than 4.0 to implement this functionality into your own project.

Follow the steps presented below:

1. In the Install Parameters page define a public property (uppercase letters only), named MY_DIR (for example).

2. In the Files and Folders page create a property-based folder using the property defined above. Add files/folders under this property-based folder.

3. In the Custom Actions page, make sure that "InstallUISequence -> Begin" and "InstallExecuteSequence -> Begin" nodes are visible in the tree control (right-click on InstallUISequence and InstallExecuteSequence and select from the context-menu "Show Standard Action -> {Before Initialization} -> Begin").

4. Create a "Property Set with Formatted" custom action under the "InstallUISequence -> Begin" section. Use the following options for this custom action:

a) Property Name: MY_DIR (defined in the "InstallParameters" page)

b) Formatted Text: [WindowsVolume]

5. Copy this custom action to "InstallExecutesSequence -> Begin" by dragging & dropping (keeping the SHIFT key pressed) this custom action in the tree control.

6. Set the Scheduling Options for the custom action to "Execute only once if present in both sequence tables".

7. Switch to the Dialogs page, right-click on "FolderDlg" and select "New Dialog" from the context-menu. A new dialog will be created in the tree control - name it "MyFolderDlg" for example. You can also select an existing dialog instead of creating a new one.

8. Add a Path Edit control and a Button control on this dialog. Set the text of the button to: [ButtonText_Browse]

9. Set the property attached to the Path Edit control to "MY_DIR".

10. For the button define the following control events in the "Published Events" tab (the first control event is a SetProperty event):

    Event         |  Argument
------------------|------------
[_BrowseProperty] |  MY_DIR
SpawnDialog       |  BrowseDlg

11. For the "Next" button from the dialog add a "SetTargetPath" control event specifying "MY_DIR" as its Argument:

    Event         |  Argument
------------------|------------
  SetTargetPath   |   MY_DIR

WarningIn the absence of this Control Event, the subfolders of the "MY_DIR" directory will be installed in the wrong location (usually in the root of the system drive) if the user enters the folder manually in the Path Edit control (instead of using the "Browse" button to select it). This event is required such that the installer is notified that the path has changed.

NoteAlso note that the Argument is "MY_DIR" and NOT the Formatted Type value "[MY_DIR]".

Privacy Policy | Windows Installer | Search Engine Ranking | Link Analyzer