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

The "ExeCa" Command

This command is used to define an EXE based custom action. It also sets up the "Action Text" which gets displayed in the progress bar. You may need to read the "Hide the DOS Command Window" section of this manual.

EXE based custom actions have many issues (see the blog "Integration Hurdles for EXE Custom Actions"), for this reason you'd never write one, however sometimes you have to use what is available! If you were starting from scratch then you'd probably write a "DLL" based one instead (perhaps using the "DllCa-C" command).

As batch files are executed via the operating system command processor, this command can also execute them, please see the "Batch File Custom Actions" section for more information.

This command takes these parameters:

EXAMPLE - Execute Installed File at End of Install

This example executes a program installed by this package. If you wish to execute an already installed executable file you would use "FileFind" to find it first.

;--- Load MAKEMSI (via my personal branding and configuration file) --------
#include "ME.MMH"

;--- Define installation directory and install file to this location --------
<$DirectoryTree Key="INSTALLDIR" Dir="[ProgramFilesFolder]\MyTestDir" CHANGE="\" PrimaryFolder="Y">
<$Component "Simple" Directory_="INSTALLDIR">
    <$File Source="c:\dbareis\tools\MsgBox.exe" RowKey="MsgBox.EXE" KeyPath="Y">
<$/Component>

;--- Invoke the install executable ------------------------------------------
#(
    ;--- Run after install, ignore return code and don't wait for completion ---
    <$ExeCa
             EXE="[INSTALLDIR]MsgBox.exe" Args=^"MsgBox Title" "MsgBox text..."^
            ;EXE="[SystemFolder]notepad.exe" Args="c:\tmp\1.x"
         WorkDir="INSTALLDIR"
             SEQ="InstallFinalize-"   Type="immediate ASync AnyRc"
       Condition="<$CONDITION_INSTALL_ONLY>"
    >
#)

EXAMPLE - Execute Program in Binary Table (not installed)

The following adds "msgbox.exe" to the "Binary" table and executes it during install:

#(
   <$ExeCa
          Binary="MSGBOX.EXE"
             EXE="c:\dbareis\tools\msgbox.exe"
            Args=^"ExeCa Test Title" "From BINARY table"^
       CONDITION=^<$VBSCA_CONDITION_INSTALL_ONLY>^
             Rc0="N"                        ;;Can't trust the return code of this program (so can't check if worked)
             Seq="InstallFiles-"
   >
#)

EXAMPLE - Regression Test for "ExeCa"

;----------------------------------------------------------------------------
;    MODULE NAME:   RegressionTests-ExeCa.MMH
;
;        $Author:   USER "Dennis"  $
;      $Revision:   1.0  $
;          $Date:   07 Oct 2004 18:09:02  $
;       $Logfile:   C:/DBAREIS/Projects.PVCS/Win32/MakeMsi/RegressionTests-ExeCa.mm.pvcs  $
;      COPYRIGHT:   (C)opyright Dennis Bareis, Australia, 2003
;                   All rights reserved.
;
;  Note that I had to pick a "EXE" that already existed for this demo...
;----------------------------------------------------------------------------

;----------------------------------------------------------------------------
;--- Include common "regression test" logic and MAKEMSI support -------------
;----------------------------------------------------------------------------
#include "RegressionTests.MMH"


;--- During Build Create some files -----------------------------------------
#( ''
    #define BuildFile
    #define SRC_{$ID} <$MAKEMSI_OTHER_DIR>\{$ID}.TXT
    <$FileMake "<$SRC_{$ID}>">
        ;--- Generate contents ----------------------------------------------
        {$ShowUser}
    <$/FileMake>
#)
<$BuildFile ID="CostFinalize"    ShowUser=^ExeCa: Early in INSTALL: After 'CostFinalize' action<?NewLine>No files from MSI installed yet.<?NewLine>Install paused until program completes (notepad exited).^>
<$BuildFile ID="InstallFiles"    ShowUser=^ExeCa: After 'InstallFiles' action<?NewLine>Any MSI files are now installed.<?NewLine>Install paused until program completes (notepad exited).^>
<$BuildFile ID="InstallFinalize" ShowUser=^ExeCa: late in INSTALL: Just before 'InstallFinalize' action<?NewLine>Any MSI files are installed.<?NewLine>Install continues (does not wait for program to exit).^>


;--- Install some files -----------------------------------------------------
<$Files "<$SRC_CostFinalize>;<$SRC_InstallFiles>;<$SRC_InstallFinalize>" DESTDIR="INSTALLDIR">


;--- Pretty Early (install waits) -------------------------------------------
#(
   <$ExeCa
             EXE="[SystemFolder]notepad.exe"
            Args=^"<$SRC_CostFinalize>"^               ;;Files not yet installed so can only access previously installed files (source)
       CONDITION=^<$VBSCA_CONDITION_INSTALL_ONLY>^
             Seq="CostFinalize-"
            Type="AnyRc Immediate"                     ;;Ignore return code. Deferred (the default) custom actions can't be sequenced here!
   >
#)


;--- After files installed (install waits) ----------------------------------
#(
   <$ExeCa
             EXE="notepad.exe"                          ;;Its in the path so "[SystemFolder]" not required.
            Args=^"[INSTALLDIR]InstallFiles.TXT"^       ;;This is NOT the source file but the installed file
       CONDITION=^<$VBSCA_CONDITION_INSTALL_ONLY>^
            Type="AnyRc"
             Seq="InstallFiles-"
   >
#)


;--- Run program neart end of install, don't wait! --------------------------
#(
   <$ExeCa
             EXE="[SystemFolder]notepad.exe"
            Args=^"[INSTALLDIR]InstallFinalize"^       ;;This is NOT the source file but the installed file
       CONDITION=^<$VBSCA_CONDITION_INSTALL_ONLY>^
             Seq="<-InstallFinalize"
            Type="AnyRc Async"                         ;;Async = don't wait (also requires AnyRc!)
   >
#)


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]: Environment[Next]: Extn


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday November 17 2013 at 1:19pm
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.