MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: DirectoryTree[Next]: DllCa
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->Commands->DirectoryTree->Directory Tree Specification

Directory Tree Specification

This describes the formatting of a directory tree specification that some MAKEMSI commands and features use to specify directories, such as:

Internally Windows Installer uses directory aliases which represent the install time directory locations where files should be placed etc. If they are associated with features then the user can choose their own alternative location (override the default) at install time. If the alias is all upper case letters the user can override from the command line.

The MAKEMSI "Directory" command can be used to create these directory aliases but it can be very annoying creating directory trees since each "level" needs to be built individually (3 commands need for "a\b\c" etc).

You can supply a directory tree in these formats:

  1. [ProgramFilesFolder]\Company X\My App
    This format specifies a directory tree where the root is a predefined directory key. The "[ProgramFilesFolder]" portion is a MAKEMSI convention (completely unrelated to Windows Installer formatting) and the "\" is optional.

    The key can be a system folder property such as "ProgramFilesFolder" (which may or may not be located at "C:\Program Files") or can be one you defined yourself (perhaps with the "DirectoryTree" command).

  2. C:\Program Files\Company X\My App
    This format is a "normal" directory. Whether or not "C:\Program Files" means the same thing as "ProgramFilesFolder" depends on how you have configured MAKEMSI (see the "MapUserDir" command).

    If the directory tree starts with "\" then the default "root" is used (specified in the "DIRTREE_ROOT" macro). This can contain something like "C:" or "[TARGETDIR]".

    If you map to particular drives then you may want to look at the "Z: Available?" launch condition.

    Where a drive letter and path is specified (and not "mapped", then that exact drive and path is used, for example, if you specify "C:\Program Files" then that is exactly where any files will go irrespective of any "ROOTDRIVE" or other approaches you might use. If the user has "Program Files" in a different location they will not be placed there (language can also play a part in the name of the standard folders)!

    To spell it out, the use of (unmapped) drive letters should be the exception rather than the rule. They should only be used if you want the files to go exactly in that location no matter what the users country, language or configuration.

    Note that you could map "C:\" to "[TARGETDIR]" if you wish.

    UNC names such as "\\SomeServer\SomeShare\SomeDir" are not (yet) supported by this command but as directories can be mapped at install time with the "PropertyCa" this is only a minor issue.

  3. Key or [Key]
    While it wouldn't make sense to use this format in the "DirectoryTree" command, other commands can supply a directory tree or the name of a previously defined directory key. As an example the "WorkDir" parameter of the "shortcut" command could specify "INSTALLDIR" or "c:\tmp".

Note that if your directory specification begins with "{" then you wish to specify a name for this directory (alternative to the use of the "NAME" parameter). The name is supplied in the form "{name}RealDirectoryName".

Naming Directories

If you prefer particular names to be used in the MSI "Directory" table (possibly because you need to refer to it by key) then you do need to be careful about the order of definition.

When MAKEMSI defines a directory it works down the tree creating any required parent directories first. Whenever it has to create a directory it either uses an "internal" name or the one you chose (if last part of directory). However MAKEMSI does not recreate directories already created so you may not get the "key" that you wish, for example the "c:\tmp" in the following example is not named "TMP" as it was created in the first step, reverse these lines (you will get an error message when you can't name a directory).

<$DirectoryTree DIRECTORY="c:\tmp\tmp2" KEY="TMP2_DIR">
<$DirectoryTree DIRECTORY="c:\tmp"      KEY="TMP">


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: DirectoryTree[Next]: DllCa


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.