canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Append to custom directory in file dialog

Hello everyone.

Is it possible to append to the custom installation location that the user choose? And is it possible to append to that already in the file dialog that the user chooses to select the custom location?

The problem with letting the user choose a different location is that the new path may not be empty. In order to avoid issues and to provide a commonly expected behavior I would like to always append "My Product V1.2" or so to whatever path the user chooses, so that it is immediately clear to them that the installer will always add that extra folder, regardless where they choose to install.


With best regards

Clemens Anhuth
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Append to custom directory in file dialog

Hi Clemens,

I'm afraid that this is not supported by Windows Installer.

However, something similar can be done with this approach:
- create a custom action which appends the version to the installation path
- go to the Custom Actions page and add it under "UI Custom Actions"
- create a ScriptInline custom action which has the "Script Text" field set to something like this:

Code: Select all

MsgBox "The installation path has been modified automatically to include the product version:" & vbcrlf & Session.Property("APPDIR"),64
- go to the Dialogs page and select the "Next" button on the "FolderDlg" dialog
- add two DoAction published control events which run your custom actions
- make sure these control events are above the "SetTargetPath" control event

Basically, the first custom action should append the version to the installation path and the second one will show a message to the user. Here is a sample custom action which appends the "ProductVersion" property to the installation path:

Code: Select all

' get the value of APPDIR
dim appdir
appdir = Session.Property("APPDIR")

' eliminate the trailing backslash
If Right(appdir, 1) = "\" Then
  appdir = Left(appdir, Len(appdir) - 1)
End If

' append the Product Version  
appdir = appdir & " " & Session.Property("ProductVersion") & "\"
Session.Property("APPDIR") = appdir
Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Append to custom directory in file dialog

Hello Cosmin,

thank you for the information, I will try that soon and hope that it'll make management happy.



With best regards

Clemens Anhuth

Return to “Common Problems”