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

The "AbortIf" Command

This command is used as a simple way to create a custom action 19 (or "LaunchCondition") which tests a "condition" and if true terminates Windows Installer with an error message.

For more complex conditions than Windows Installer can handle you could use the "VbsCa" command.

The macro takes these parameters:

EXAMPLE 1

We only want to install this product on Windows 2000, XP or above:

<$AbortIf Condition=^not VersionNT OR (VersionNT < 500)^ Message=^Can only be installed on Windows 2000, XP or greater.^>

The condition "not VersionNT" is checking to see if the "VersionNT" property exists (it won't for WIN95, WIN98 and WINME) and "VersionNT < 500" is checking if the NT version is less than "5.00" (correct value for WIN2000).

See the online documentation for a list of operating system related property values.

EXAMPLE 2

;--- Define the list of properties we require (3 in this case) --------------
#( ";"
   #define REQUIRED_MSIEXEC_PROPERTIES

   CENTRAL_SERVER
   LOCAL_SERVER
   SOME_OTHER_THIRD
#)

;--- Make sure they exist ---------------------------------------------------
#{ SET ^Property={;}<$REQUIRED_MSIEXEC_PROPERTIES>^
   #(
       ;--- Test for non-existance of property (INSTALL time only) ----------
       <$AbortIf
           Condition=^NOT <??SET_Property> and not Installed^
           Message=^The property "<??SET_Property>" must be
                   specified on the MSIEXEC command line
                   during installation.
                   The complete list is "<$REQUIRED_MSIEXEC_PROPERTIES>"!^
       >
   #)
#}

EXAMPLE 3 - 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">
#)


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]: The 'VbExp' Macro[Next]: Access


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.