Link to home
Start Free TrialLog in
Avatar of Ernest Cook
Ernest CookFlag for United States of America

asked on

Installshield issue with past versions

I have an installshield program that works fine in terms of saving local files, data files registration information but with previous installations of the product (not controlled by Install shield)  those files are deleted during the reinstall
Avatar of Darren Collins
Darren Collins
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi Ernest,  

I'm not sure exactly what the problem is from your question.  Can you please list the steps you've performed that result in the problem?  For example,
1. created an msi to deliver files and registry entries
2. installed new msi on system to upgrade x
... etc.

And could you also please explain the format / packaging format of the 'old' installations.

Daz.
Avatar of Ernest Cook

ASKER

Let me be a bit clearer.  The original installer was using the Microsoft VS 2010 setup program for building a MSI.  It had a C# setup extension program with this code:

       public override void Uninstall(IDictionary mySavedState)
        {
            if (mySavedState == null)
            {
                //Console.WriteLine("Uninstallation Error !");
                //string[] dirs =Directory.GetDirectories(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));

                //if (dirs.Contains("TBX"))
                //{
                    string strMyDocument = string.Empty;
                    try
                    {
                        strMyDocument = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\TBX";
                    }
                    catch
                    {
                        return;
                    }
                    if (Directory.Exists(strMyDocument))
                    {
                        string[] files = Directory.GetFiles(strMyDocument);
                        foreach (string file in files)
                        { File.SetAttributes(file, FileAttributes.Normal);
                            File.Delete(file);
                        }
                        //Directory.Delete(strMyDocument,true);
                        DirectoryInfo dirInfor = new DirectoryInfo(strMyDocument);
                        dirInfor.Delete(true);
                    }
                //}
            }
            else
            {                base.Uninstall(mySavedState);      }
        }
    }


Typically only 2 files are stored and need to be saved:
--a class.txt file
--a xml based file that stores registration information.  

When I upgraded the code to VS2015 I also switched to the Installshield limited edition for building the setup.

Both setup programs work well as far as creating the default directories etc as well as saving any files that might be around already except, when a target computer has an installation from the VS2010 installer. In that case, the 2 files mentioned above that should be in
C:\ProgramData\TBX
are deleted during the installation. :-(
Hi Ernest,  I must apologise for not following back up with this.

It sounds like your new msi is an upgrade of the old msi.  Usually, when a home-grown msi upgrades another and the file disappears instead of being upgraded it is because the component GUIDs of the identically-named files are not aligned.  By default msi's upgrade by installing the new one then uninstalling the old one. If the GUIDs are not aligned it can't know that you intended to keep the file, and therefore will remove it.

The Easiest fix for this is to move the position of the RemoveExistingProducts action in the newer msi.  This way you can make the msi uninstall the old one before installing the upgraded msi.

Please see this excellent page for reference - I've been using it for years:
https://jpassing.com/2007/06/16/where-to-place-removeexistingproducts-in-a-major-msi-upgrade/

Basically I recommend that you move RemoveExistingProducts  to between InstallValidate and InstallInitialize.  This will action the clean Remove Old / Install New sequence that it looks like you need.

First make a copy of your msi so that you can get back if you need to.  
Then you can do this in InstallShield using the Installation Designer Direct Editor (at the bottom).  Select the InstallExecuteSequence table and sort the table by the Sequence column.  Scroll down to the RemoveExistingProducts Action, and change the Sequence number to a number between the one allocated to InstallValidate and the one allocated to InstallInitialize.  Any number between those two should be fine.

I hope this helps and apologies again.
Daz.
After the delete request a new answer came in. I am trying that answer which may turn out to be a good resource on this network.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.