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]: Sweep (Execute command(s) per File or Directory)[Next]: Magic Tweeks
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Batch Files->Batch File Custom Actions

Batch File Custom Actions

A batch file is not an executable file so it must be executed via the appropriate command process for the operating system ("command.com" or "cmd.exe").

The "/c" option tells the command processor to return after executing the command. The example below checks for return code, you may or may not want to ignore any return code.

You will notice the "hack" that is required for WINNT+, this should not be required for "command.com". The "VersionNT" and "Version9X" are some of the "properties" that you can use in the custom action's condition.

You will probably also wish to test the generated MSI on multiple operating systems and the use of "virtual machines" is probably the best way of doing this.

<$Component "BatchFile" Directory_="INSTALLDIR">
    ;--- Create Our Batch file (obviously you may already have one) ---------
    #define OurBatchFile_SN LaunchedAtEnd.BAT
    #define OurBatchFile    <$MAKEMSI_OTHER_DIR>\<$OurBatchFile_SN>
    <$FileMake "<$OurBatchFile>">
            @echo off
            #(
            .\MsgBox.exe /II "EXECA for .BAT" "Hi there.
                             A batch file invoked by the ExeCa command
                             (product '<$ProdInfo.ProductName> version <$ProductVersion>)
                             is displaying this message.
                             The Installation directory is '%1'."
            #)
            @rem pause
    <$/FileMake>

    ;--- Add the batch file -------------------------------------------------
    <$File Source="<$OurBatchFile>" KeyPath="Y">

    ;--- Our batch file will invoke this (to make it obvious it was called etc) ---
    <$File Source="c:\dbareis\tools\MsgBox.exe">
<$/Component>

;--- Invoke the batch file (probably work in WinNT/Win2000/WinXP) -----------
#define CmdExeFix  "            ;;CMD.EXE "feature". Thanks MS...
#(
    <$ExeCa
            EXE=^cmd.exe^                                      ;;NOTE: "Command.com needed for Win95-WinME"
           Args=^/c <$CmdExeFix>"[INSTALLDIR]<$OurBatchFile_SN>" "[INSTALLDIR]"<$CmdExeFix>^
        WorkDir="INSTALLDIR"                                   ;;Current directory MUST be MSGBOX directory!
      Condition=^<$CONDITION_EXCEPT_UNINSTALL> and VersionNT^  ;;Install or Repair, note: not checking if silent or not here!
            Seq="StartServices-"

    >
#)


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 27 Dec 2008Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Sweep (Execute command(s) per File or Directory)[Next]: Magic Tweeks


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday December 27 2008 at 3:15pm
Visit MAKEMSI's Home PageThis external link was OK when tested at 7 Dec 2008

HTML page dated Mon, 29 Jan 2007 00:11:11 GMT
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 27 Dec 2008