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]: Property[Next]: PropertyList
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->Commands->PropertyCa

The "PropertyCa" Command

This command is used to create or update the value of a Windows Installer property (or directory key).

This command differs from the "Property" command in that the property assignment is scheduled as a custom action type 51 (or 35 for directories). This allows you to "capture" the current value of properties at runtime.

This command takes these parameters:

EXAMPLE

This example show how the "CustomActionData" property is set up prior to calling a deferred custom action. Note that to do this I set the "key" on the "VbsCaSetup" command so I knew exactly what the key was, I then created a property of the same name, Windows Installer will do the rest.

In this case I am passing two properties, the custom action will need to separate these values, painful but required.

<$PropertyCa     "MyCa_Install" Value="[INSTALLDIR];[SecondProperty]" Seq="InstallFiles-">
<$VbsCaSetup Key="MyCa_Install" Binary="MyCa.vbs" Entry="Install"     Seq="InstallFiles-" CONDITION=^<$VBSCA_CONDITION_INSTALL_ONLY>^>

EXAMPLE - Overriding 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">

EXAMPLE - Macro to Find "WSCRIPT.EXE"

;##################################################################################
;### Note that I have now created a "FileFindInListedDirs" command
;### which simplifies this and makes it more generic:
;###       <$FileFindInListedDirs File="wscript.exe" DIRS="System64Folder;SystemFolder;WindowsFolder">
;##################################################################################

;----------------------------------------------------------------------------
;--- Macro to find "WSCRIPT.EXE"
;--- MS stupidly places this file in logically different locations
;--- ("C:\windows" in WIN98). Also just to make it more difficult it is not
;--- possible to search by attribute, or search path and thus not possible
;--- to avoid possible incorrect matches in fixpack backup directories.
;--- All in all nearly a handful of reasons to swear at MS in one go....
;----------------------------------------------------------------------------
#(
    #define WSCRIPT.EXE

    ;--- Can't do this! Can find files in "$NtServicePackUninstall" type directories ---
    ;<$FileFind File="WSCRIPT.EXE" Property="WSCRIPT.EXE" PATH="[WindowsFolder]" Depth="1">   ;;Danger, Danger...

    ;--- Thanks MS... -------------------------------------------------------
    <$FileFind File="WSCRIPT.EXE" Property="WSCRIPT.EXE.WF" PATH="[WindowsFolder]" Depth="0" Default="">
    <$FileFind File="WSCRIPT.EXE" Property="WSCRIPT.EXE.SF" PATH="[SystemFolder]"  Depth="0" Default="">
    <$PropertyCa "WSCRIPT.EXE" Value="[WSCRIPT.EXE.WF]" Seq="AppSearch-" Condition="WSCRIPT.EXE.WF and (<$CONDITION_EXCEPT_UNINSTALL>)" SeqTable="InstallUISequence InstallExecuteSequence">
    <$PropertyCa "WSCRIPT.EXE" Value="[WSCRIPT.EXE.SF]" Seq="AppSearch-" Condition="WSCRIPT.EXE.SF and (<$CONDITION_EXCEPT_UNINSTALL>)" SeqTable="InstallUISequence InstallExecuteSequence">
    <$AbortIf
        Condition="not WSCRIPT.EXE and (<$CONDITION_EXCEPT_UNINSTALL>)"
          Message=^The file "WSCRIPT.EXE" was not found in the "[WindowsFolder]" or "[SystemFolder]" directories!^
         SeqTable="InstallUISequence InstallExecuteSequence"
              Seq="AppSearch-"
    >
    <$PropertyList "SecureCustomProperties" Value="WSCRIPT.EXE">
#)

EXAMPLE - "*VALUE" Parameter

The following shows the the "*value" parameter being used:

<$PropertyCa "CompileTimeBuild1"  Value="<?CompileTime>" Seq="CostFinalize-">   ;;Date/Time of build start from PPWIZARD standard definition
<$PropertyCa "CompileTimeBuild2" *Value="cstr( time() )" Seq="CostFinalize-">   ;;Time from VBSCRIPT expression (executed later during pass #1)


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]: Property[Next]: PropertyList


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.