We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

asia.shafran
Posts: 9
Joined: Wed Jan 18, 2017 12:53 pm

How to reinstall if upgrade failed

I have some installation exe file
I am installing my program, and later I can update to a new version
I want that if upgrade failed for some reason - it will reinstall the previous version


So I tried few options:
1. To set "Install new version first and than uninstall old version" - it doesn't work cause Im overriding most of the files so it
2. To create new custom action that I put in the end of all other actions, I set it to "during installation rollback" and Execution Stage Condition I set to "Upgrade" - but for some reason if I press 'cancel' during the upgrade - sometime the action is called and sometimes it doesn't.. Is it correct to put the rollback script in the end of all actions? when exactly this code should run?

Is there any other good way to do reinstall if upgrade is failing?
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: How to reinstall if upgrade failed

Hello,

The correct approach to achieve what you need is to use the the "Install new version first and than uninstall old version" upgrade option. However, when using this option you should make sure no component GUID is changing from one version to another and also you should be aware of the know problems which could initiated by this upgrade order.
2. To create new custom action that I put in the end of all other actions, I set it to "during installation rollback" and Execution Stage Condition I set to "Upgrade" - but for some reason if I press 'cancel' during the upgrade - sometime the action is called and sometimes it doesn't.. Is it correct to put the rollback script in the end of all actions? when exactly this code should run?
The rollback script should be added just after the "Install Execution Stage -> Preparing" action group.
Is there any other good way to do reinstall if upgrade is failing?
I'm afraid not.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
asia.shafran
Posts: 9
Joined: Wed Jan 18, 2017 12:53 pm

Re: How to reinstall if upgrade failed

Can you explain me the behavior of "install new version and than uninstall old version" - what will it do about files that are overridden because of the installation of the new version??
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: How to reinstall if upgrade failed

Hello,

When this option is used this is what happens:
1. new version is installed and the new installation files overwrite the existing files; if the new files are in the same components (same GUIDs) as the old files then Windows Installer will increment a ref count (e.g. from 1 to 2) - the ref count is maintained for every component - this means that there are two products sharing the same component and in this case the component files will be uninstalled only when there is no installed product referencing the component
2. the old version is uninstalled; during uninstall Windows Installer decrements the ref count of the old product components; if there are components with a ref count set to 0 (they were not shared in the new product with the same GUIDs) the component resources will be uninstalled

This is why you should be extremely careful NOT to change the GUID of any component from an old product version to a newer one.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”