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]: IIS Installed?[Next]: Prevent Downgrades of Your Product
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Launch Conditions->MDAC not too old?

Launch Condition: MDAC not too old?

This is an example of a macro call which will validate that the level of MDAC your application requires is available:

<$ValidateMdacVersion LowestVersion="2.82">

The follow code is what actually implements the macro you used above:

#(
    #define ValidateMdacVersion

    ;--- Validate parameters ------------------------------------------------
    {$!:LOWESTVERSION}          ;;Lists all valid parameters

    ;--- Make sure we know how to insert the file version compare code ------
    #ifndef  INCLUDE_VBSCRIPT_FUNCTION-CompareFileVersions
        #error ^You must define the file version compare code in the{NL}macro "INCLUDE_VBSCRIPT_FUNCTION-CompareFileVersions",{NL}See the MAKEMSI tip in the manual!^
    #endif

    ;--- Only allowed once (or specify the same version) --------------------
    #ifdef  @@CheckedMdacVersion
        ;--- This is not the first time, check same version! ----------------
        #if  ['<$@@CheckedMdacVersion>' <> '{$LowestVersion}']
            #error ^You wish to check for MDAC "{$LowestVersion}" however you have previously also specified version "<$@@CheckedMdacVersion>"!^
        #endif
    #elseif
        ;--- First time so record the version and flag it -------------------
        #define @@CheckedMdacVersion {$LowestVersion}

        ;--- Get the value from the registry (could also do in script) ------
        #(
            <$RegistryRead
                Property="MDACVERSION"
                    HKEY="LOCAL_MACHINE"
                     KEY="Software\Microsoft\DataAccess"
                    NAME="FullInstallVer"       ;;See MSDN Article #301202
            >
        #)

        ;--- Adjust the value to something Windows Installer can compare ----
        <$VbsCa Binary="SeeIfMdacVersionIsHighEnough.vbs">
        #( '<?NewLine>'
           <$VbsCaEntry "Install">
                ;--- Init ---------------------------------------------------
                dim RequiredVer, InstalledVer
                RequiredVer = "{$LowestVersion}"
                CaDebug 1, "Validating MDAC version (must be at least " & RequiredVer & ")"
                InstalledVer = VbsCaPropertyGet("MDACVERSION", "2.52.5566", "")
                CaDebug 2, "MDAC version " & InstalledVer & " is installed."

                ;--- Compare ------------------------------------------------
                CaDebug 0, "Comparing the versions..."
                dim CompRc, PropertyValue
                CompRc = CompareFileVersions(InstalledVer, RequiredVer)
                if  CompRc = <$FILEVER_RC_F1_EQUAL_F2> or CompRc = <$FILEVER_RC_F1_GREATER_THAN_F2> then
                    PropertyValue = "OK"
                else
                    PropertyValue = "ERROR"
                end if

                ;--- set the property ---------------------------------------
                CaDebug 0, "Setting property to: " & PropertyValue
                session.Property("MDAC_STATUS") = PropertyValue
           <$/VbsCaEntry>

           ;--- Add required compare function(s) ----------------------------
           <$INCLUDE_VBSCRIPT_FUNCTION-CompareFileVersions>
        #)
        <$/VbsCa>
        <$VbsCaSetup Binary="SeeIfMdacVersionIsHighEnough.vbs" Entry="Install" Seq="AppSearch-" SeqTable=^{$SeqTable='InstallUISequence InstallExecuteSequence'}^ TYPE="immediate" Key="SeeIfMdacVersionIsHighEnough.vbs" CONDITION=^<$CONDITION_INSTALL_ONLY>^>

        ;--- Now report any problem (could also be done in CA) --------------
        #(
            <$AbortIf
               Condition=^MDAC_STATUS <> "OK"^
                 Message=^This product (<$ProdInfo.ProductName>) requires MDAC version {$LowestVersion} or later. Only MDAC version "[MDACVERSION]" is installed, please upgrade before trying again.^
                     Seq="AppSearch-"
                SeqTable=^{$SeqTable}^
                    Key="AbortIfMdacVersionLessThan{$LowestVersion}"
            >
        #)
    #endif
#)

The above code made use of a macro described in the "File Version Compare Code" tip.


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 23 Aug 2008Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: IIS Installed?[Next]: Prevent Downgrades of Your Product


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Thursday August 28 2008 at 11:28am
Visit MAKEMSI's Home PageThis external link was OK when tested at 13 Aug 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 23 Aug 2008