Setting Minor or Major Upgrade within InstallScript Project

1.2k Views Asked by At

I'm using InstallShield 2012 Spring - Premier Edition and I'm trying to replace the existing install of our software (if it exists) with whatever is in the new Setup script when Setup script is run again.

I have read some things online that say to configure Minor and Major upgrade settings.

I have an InstallScript Project and I cannot find how to do Minor and Major upgrades, like it can be done with Basic MSI projects. I read online that this can be done with MSI projects by going to Installation Designer and then Media/Upgrades and then configure the upgrade. This option is not available within InstallScript projects.

What can I use with InstallScript projects to change this behavior? Thank you in advance.

1

There are 1 best solutions below

8
Steve On

I believe you need to add a few more event handlers to your main script. To start, you'll need to add the following handlers if they're not already present:

  • OnShowUI
  • OnUpdateUIBefore
  • OnUpdateUIAfter
  • OnMaintUIBefore
  • OnMaintUIAfter

The important thing is to have OnShowUI in order to run the appropriate "Before" method. Below is what I do; you'll need to do whatever you need to do in the other methods (mine are pretty domain-specific and I can't provide those directly).

//---------------------------------------------------------------------------
// OnShowUI
//
// This function drives the UI sequence and file transfer of the setup.
// 
// The OnShowUI event is called directly by the framework to initiate
// the UI sequence and file transfer of the setup. By default this event
// displays UI that informs the end user that the maintenance setup has been
// completed successfully.
//---------------------------------------------------------------------------
function OnShowUI()
    BOOL bMaintenanceMode, bUpdateMode;
    string szIgnore, szTitle;
    LIST listDirs;
    number nFindAllDirsResult, nFindAllFilesResult;
    BOOL lDirEmpty;

begin
    // Enable dialog caching
    Enable( DIALOGCACHE );

    // Determine what events to show
    bUpdateMode = FALSE;
    bMaintenanceMode = FALSE;

    // Remove this to disabled update mode
    if (UPDATEMODE) then
        // checking to make sure app still exists in orig location
        if Is(PATH_EXISTS, TARGETDIR) then
            // Also check for empty TargetDir
            lDirEmpty = IsTargetDirEmpty();

            if (lDirEmpty) then
                // TARGETDIR is completely empty, so disable UPDATE mode
                bUpdateMode = FALSE;
            else
                // TARGETDIR has some contents, so continue with UPDATE
                bUpdateMode = TRUE;
            endif;
        else
            // Turn off Update mode if original folder is gone
            bUpdateMode = FALSE;
        endif;

        if (!bUpdateMode) then
            // If Update mode is set but the original target is missing
            // need to flag the installer to force full reinstall (otherwise it will 
            // think all features have already been installed (by analyzing the log))
            FeatureReinstall();
        endif;
    endif;

    // Remove this to disable maintenance mode.
    if (MAINTENANCE) then
        // checking to make sure app still exists in orig location
        if Is(PATH_EXISTS, TARGETDIR) then
            // Also check for empty TargetDir
            lDirEmpty = IsTargetDirEmpty();

            if (lDirEmpty) then
                // TARGETDIR is completely empty, so disable Maint mode
                bMaintenanceMode = FALSE;
            else
                // TARGETDIR has some contents, so continue with Maint
                bMaintenanceMode = TRUE;
            endif;
        else
            // Turn off maintenance mode if original folder is gone
            bMaintenanceMode = FALSE;
        endif;

        if (!bMaintenanceMode) then
            // If Maintenance mode is set but the original target is missing
            // need to flag the installer to force full reinstall (otherwise it will
            // think all features have already been installed (by analyzing the log))
            FeatureReinstall();
        endif;
    endif;

    // Show appropriate UI

    if( bUpdateMode ) then
        OnUpdateUIBefore();
    else
        if ( bMaintenanceMode ) then
            OnMaintUIBefore();
        else
            OnFirstUIBefore();
        endif;
    endif;

    // Move Data
    OnMoveData();

    if( bUpdateMode ) then
        OnUpdateUIAfter();
    else
        if ( bMaintenanceMode ) then
            OnMaintUIAfter();
        else
            OnFirstUIAfter();
        endif;
    endif;

    // Disable dialog caching
    Disable(DIALOGCACHE);
end;

I will say that in the OnUpdateUIBefore, I commented out the following code:

// Check whether the update is needed.
if( nResult = VERSION_COMPARE_RESULT_SAME ) then
    // Note: This result should occur only for differential media, since the setup
    // will display OnMaintUIBefore or OnFirstUIBefore by default if the versions match
    // for full setup media.
    szMsg = SdLoadString( IDS_IFX_WARNING_UPDATE_NOT_NEEDED );
    SdSubstituteProductInfo( szMsg );
    if( MessageBox( szMsg, MB_ICONEXCLAMATION | MB_YESNO ) != IDYES ) then
        abort;
    endif;
endif;

I don't remember why, but I suspect it was causing the Update mode to not work as I expected.

I automate my Installshield builds (via COM--see this answer for basic info if interested) and part of that process involves incrementing the minor version in order to trigger Update Mode when the new installer is ran against an older version.

Good luck!