Posts: 1085
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

How to upgrade an older version of the package created with another tool and it is not MSI-based

Hello guys,

There are cases when you want to upgrade an old packge which is created with another tool and it is not MSI-based.

Usually, these packages have an Uninstaller which is triggered by Windows Installer when you manually remove it from the Control Panel.
To remove it from your new package, you can use a "Launch file" custom action to launch the Uninstaller of the old product.

The uninstaller path is saved by Windows Installer in the following registry key:
  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
  • Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\
    if your old package is installed per-user.
This key stores the information needed to uninstall a (properly) installed program (software) or application.
Each uninstallable application is stored in a subkey whose name sometimes is a GUID (in curly braces).

The same uninstaller is also trigger by Windows Installer when you remove the old package from the Control Panel.

In this tutorial you will find how to remove the old package (not MSI-based) and install the new version of your application.

Let's suppose that our old package is "7-Zip" which is not MSI-based and is installed per-machine. The uninstall string can be found in the following registry:
registry.png (96.89 KiB) Viewed 349675 times

1. Create a new project in Advanced Installer (Professional type or higher).

2. Since the 7-Zip is installed as a 64-bit package on my machine, the new setup will be also 64-bit package. Therefore from the "Install Parameters" page" I changed the package type to "64-bit package".

3. Go to the "Search" page.

4. Click on the "New Search" toolbar button.

5. Click on the "Add Search Location" --> "Registry".

6. Configure the search like this:
search.png (102.51 KiB) Viewed 349675 times

If we use the "Retrieve the raw value" option, it will contain the quotation mark and therefore our Launch file custom action will fail.

In this case, we need to use the "The value contains a path to a file" type.

7. Also, always test the search operation to make sure the path is retrieved correctly:
test search.png
test search.png (102.71 KiB) Viewed 349675 times

8. Now you can use the search property to trigger the uninstall of the old package. For that, go to the "Custom Actions" page and add a "Launch File" custom action scheduled after "Searches" action group in the Wizard Dialogs stage.

  • On the "File to launch" field we need to add the [RESULT_PROPERTY] property which will be resolved to the following path: C:\Program Files\7-Zip\
    Therefore, we need to manually add the Uninstall.exe in this field.
  • On the command line field you can add parameters (for example if you want to uninstall it silently). For the 7-Zip you can add the "/S" parameter and it will be silently removed.
  • You can check the "Run as administrator" option if your old uninstaller package requires administrator privileges in order to be removed.
  • Make sure to uncheck the "Fail installation if custom action returns an error" option. Custom actions that are executable files must return a value of 0 for success. The installer interprets any other return value as failure. This is because we do not know what will be the return code from your old setup (maybe will be 2 for success, case in which the new setup will fail).
  • Uncheck the "Uninstall" and "Maintenance" options under the Dialogs Stage Condition.
  • You can also add the "RESULT_PROPERTY" condition for your custom action. This means the custom action will be executed only if the UninstallString value for your old package exists in the registry.
9. If you do not uninstall the old package silently, the uninstall.exe will be launched right after you new setup. This may create confusion for your customers (the new setup is launched and immediately an uninstallation is triggered).
In this case, you can inform the customers that an old package has been detected and is going to be uninstalled.
For that, you can use a MessageBox custom action wih the "RESULT_PROPERTY" condition. For example a messsage like this: "Old package detected. Please uninstall the old package before proceeding...".
messageBox.png (171.13 KiB) Viewed 349675 times

If your old package does not have its own Uninstaller, you need to create an uninstall mechanism (e.g. uninstall script). However, when you create the uninstall script you need to take into consideration that the custom action must remove all the resources (files, registry entries etc.) created by the old installation.

That's all! Attached you can find the sample project.

Hope this helps!

Best regards,
(14.51 KiB) Downloaded 3214 times
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”