March 2010 - Posts

Getting additional Standard Folders in Windows Installer

Windows installer includes a number of pre-defined properties for standard folders such as ProgramFilesFolder. Other standard folders are available as environment variables, such as %ALLUSERSPROFILE%, which can be used similar to properties in the form [%ALLUSERSPROFILE].

However these properties and environment variables don't cover all standard folders, and Windows Installer didn't keep up with system folders that were added in newer Windows versions.

In the ONtrex blog, Fabio Di Lorenzo has posted a script that retrieves the values of such special folders using their CSIDL_* value, and stores the result in a property.

The blog post is written in German, so here's a summary in English:

Essentially you need to create the following VBScript custom action and schedule it before CostFinalize.

Const CSIDL_COMMON_DOCUMENTS = &h2e
Set objShell = CreateObject(“Shell.Application”)
Session.Property(“ONTX_COMMON_DOCUMENTS”) = objShell.Namespace(CSIDL_COMMON_DOCUMENTS).Self.Path
Set objShell = nothing

where ONTX_COMMON_DOCUMENTS is your custom property in which you want to store the resulting path. A list of the CSIDL constants and their meaning can be found in the original blog post - this part is in English.

Posted by stefan | with no comments