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]: Z: Available?[Next]: Patch Creation
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Overriding & Remembering the Installation Directory

Overriding the Installation Directory

The following is an example where the installation directory is specified by an environment variable but it could just as easily have been created via an immediate "VbsCa" custom action.

Note that Windows Installer remembers the location for repair and uninstall (at least where at least one file is installed there).

#define ENVVAR_INSTALLDIR       SOME_ENV_VAR        ;;Name of environment variable containing a path...
<$DirectoryTree Key="INSTALLDIR" Dir="C:\DummyLocation" CHANGE="\" PrimaryFolder="Y">
#(
    ;--- Check that the environment variable holding the install dir exists! ---
    <$AbortIf
        Condition=^%<$ENVVAR_INSTALLDIR> = "" and <$CONDITION_INSTALL_ONLY>^
              Seq=^CostFinalize-^ SeqTable="InstallUISequence InstallExecuteSequence"
          Message=^The "<$ENVVAR_INSTALLDIR>" environment variable doesn't exist. We can't determine the installation directory.^
    >

    ;--- Set the installation directory to the value of the environment variable ---
    <$PropertyCa "INSTALLDIR" Value="[%<$ENVVAR_INSTALLDIR>]"
              DIR="Y"
        Condition=^<$CONDITION_INSTALL_ONLY>^ Seq=^CostFinalize-^ SeqTable="InstallUISequence InstallExecuteSequence"
    >
#)

;--- Install files ----------------------------------------------------------
<$Files "TryMe.*" DestDir="INSTALLDIR">

Remember the Install location

This shows one way you can insure that the install location (in this case "INSTALLDIR") is remembered but defaults to a good value the first time:

;--- Create INSTALLDIR (remember where user wishes it installed) ------------
<$Property "INSTALLDIR" Persist="Y" PersistHow="PRODUCT FOREVER">
<$DirectoryTree Key="INSTALLDIR" Dir="[ProgramFilesFolder]\SomeProduct" CHANGE="\" PrimaryFolder="Y">
...

Note that the "PropertyCa" was not needed in the above, if you need to "work out" the correct install location then it would probably be used to set the "INSTALLDIR" property's value (with or without the "DIR" parameter specified as "Y").


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]: Z: Available?[Next]: Patch Creation


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday February 28 2016 at 3:45pm
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.