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]: Create Macro For Adding Files[Next]: Debug Macro - Wait While Displaying Message
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Debug Macro - Cause Rollback (or just failure)

Debug Macro - Cause Rollback (or just failure)

This demonstrates a relatively simple but very useful debugging macro with can be used for two main reasons:

  1. You wish to test other rollback custom actions by simulating a failure during an install.

  2. You want to test something over and over without the need to restore state yourself, for example you want to test install but don't wish to keep uninstalling it!

This command causes a failure. By default it creates "deferred custom actions" scheduled as close as possible to "InstallFinalize" to try to cover all rollbackable installation activity.

The 'DebugCauseFailure' (or 'DebugRollback') Code

;-----------------------------------------------------------------------------
;--- DEBUG MACRO: RollBack (use to abort install/repair/uninstall activity ---
;-----------------------------------------------------------------------------
#( '<?NewLine>'
    #define DebugRollback                   ;;Version 08.241

    ;--- Validate parameters and keep count ---------------------------------
    {$!:SEQ,SEQTABLE,TYPE,CONDITION}
    #RexxVar RxDebugRollBackCnt + 1     ;;Inc Count (need diff binaries as conditions, scheduling may/will differ)

    ;--- Don't do anything in production mode! ------------------------------
    #if ['<$MmMode>' = '<$MMMODE_PRODUCTION>']
        ;--- In production mode warn first time -----------------------------
        #if [RxDebugRollBackCnt = 1]
            #info ^DebugRollback not inserted in production mode!^
        #endif
    #elseif
        ;--- Not Production mode --------------------------------------------
        <$VbsCa Binary="DebugRollback_<??RxDebugRollBackCnt>.vbs">
           <$VbsCaEntry "FailedOnPurpose">
               #(
                    VbsCaRaiseError "FailedOnPurpose()",
                                    "<$DebugCauseFailureMsg>" & vbCRLF &
                                    vbCRLF &
                                    "MSI       : <$ProdInfo.ProductName> v<$ProductVersion> (build <?CompileTime>)"  & vbCRLF &
                                    "Sequenced : {$Seq=^<-InstallFinalize^}  (in {$SeqTable=^InstallExecuteSequence^})"  & vbCRLF &
                                    "Condition : {$Condition=~<$CONDITION_INSTALL_ONLY>~}"  & vbCRLF &
                                    "CA Type   : {$Type=^Deferred^}"  & vbCRLF &
                                    "Defined   : <??RxMmLocation>"
               #)
           <$/VbsCaEntry>
        <$/VbsCa>
        <$VbsCaSetup Binary="DebugRollback_<??RxDebugRollBackCnt>.vbs" Entry="FailedOnPurpose" Seq="{$Seq}" CONDITION=^{$Condition}^ Type="{$Type}" SeqTable="{$SeqTable}">
    #endif
#)
#RexxVar RxDebugRollBackCnt = 0         ;;Init count
#(
    #define? DebugCauseFailureMsg
    We are causing a failure on purpose,
    perhaps to test rollback or because we want to test an install
    over and over again without needing to uninstall all the time!
#)
#define DebugCauseFailure <$DebugRollback {$?}>             ;;Create an alias for the macro.

The follow shows how the macro could be used:

<$DebugRollback>


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]: Create Macro For Adding Files[Next]: Debug Macro - Wait While Displaying Message


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday December 09 2017 at 9:30am
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.