2

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.

DiegoS
  • 816
  • 1
  • 10
  • 26
Grapefruit
  • 21
  • 4
  • Are you needing to have the ability to update the minor/major version via the script? If you just need to update it via the InstallShield interface, you can do so via Settings in the Project menu. On the Application tab of the Project Settings dialog, you can update the Product Version value. – Steve Mar 10 '17 at 16:37
  • What I want to accomplish is when the user runs the setup script for the second time, that it overwrites the existing install if it exists. Right now, even if I bump the product version, it enters the maintenance mode and asks to uninstall first and I don't want that. Since this is an InstallScript Project, I don't have the option to set major and minor upgrades. – Grapefruit Mar 10 '17 at 16:55
  • I am trying to get InstallScript Project to overwrite previous install without uninstall if that makes more sense. – Grapefruit Mar 10 '17 at 17:04
  • OK, I see. I have gone through the exact same problem. You're sort of half way there by updating the version number, but there also needs to be some additional code added to your script to detect UPDATE vs MAINT mode. I'm going to post an answer below of what I _think_ solves your problem (or at least get you on the right track). Hope it helps. – Steve Mar 10 '17 at 17:21
  • InstallScript or InstallScript MSI project type? – Christopher Painter Mar 13 '17 at 00:21

1 Answers1

0

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!

Community
  • 1
  • 1
Steve
  • 506
  • 6
  • 16
  • With your changes to function OnShowUI(), could please explain how the code you modified for "if (UPDATEMODE) then" and "if (MAINTENANCE) then" would make the setup script skip the uninstall and overwrite an existing install? I see you added checks if TARGETDIR is completely empty but I don't understand how will that suppress the maintenance mode/uninstall screen and do a full install over the existing one? – Grapefruit Mar 10 '17 at 18:30
  • I would suggest disabling Uninstall and Maintenance mode in the Project Settings. With my technique, installing a new version on top of an existing installation would simply add any new files in the new build or update existing files if any in the new build have been updated. In other words, it won't completely reinstall from scratch. – Steve Mar 10 '17 at 18:52
  • What Maintenance Experience do you use for this: "Standard" or "No uninstall or maintenance"? – Grapefruit Mar 10 '17 at 18:59
  • I use Standard. But, if my example can be any indication, it can be pretty tricky (if not nearly impossible) to get things working just like you want. Sometimes for sanity sake it's just best to have no uninstall/maintenance (I've had to go down that road before). – Steve Mar 10 '17 at 19:24
  • I see. The only problem using "No uninstall or maintenance" is that I don't have the ability to uninstall the software from Add or Remove Programs. So if I understand correctly, I if I change function OnShowUI() like you did and then comment out the section in OnUpdateUIBefore like you did, I will be able to run my setup script and it will overwrite the files as if it were an update and I will still have the ability to uninstall it from Add or Remove Programs? – Grapefruit Mar 10 '17 at 19:38
  • Basically, yes. However, it's possible you'll have some trial and error in the script (I know I did). And if Update mode is triggered (new installer's version is greater than what's currently installed) only new/updated files will get installed (hopefully that's OK in your situation). That is nice as update installs are much quicker than fresh installs. Also don't forget you can use the script debugger to help see how things flow. – Steve Mar 10 '17 at 19:45
  • Thank you for clarifying things. So even if Maintenance Experience is set to "Standard", the scripts will not go into maintenance mode if the major and minor versions of the product are different but will use the update mode? Only if the major and minor versions of the product are the same, then the maintenance mode is triggered. Right? – Grapefruit Mar 10 '17 at 20:57
  • I believe that is the default behavior, yes. – Steve Mar 10 '17 at 23:20