Msiexec: automatic rollback to previous version on installation failure
Asked Answered
R

3

7

When installing a .MSI file using msiexec in silent mode, is it possible to automate it such that on installation failure it rollbacks to the previous version? Assuming that on installation an older application version is already installed.

Resolutive answered 16/11, 2011 at 16:27 Comment(1)
Yes, this is possible by using a minor upgrade or a properly sequenced major upgrade that uninstalls the older versions after successfully updating all files. If the major upgrade is set to uninstall the old version before installing the new, the rollback is not available. For minor upgrades and for late uninstall of old version in major upgrades to work correctly, all MSI component rules must be followed 100% accurately.Merrow
C
2

Yes, restoring the old application version via rollback upon an installation failure is actually a built-in feature of Windows Installer, but you need to configure things correctly to get it to work as you require.

Windows Installer rollback will work as you request if you use: 1) a minor upgrade or 2) a properly sequenced major upgrade that uninstalls the older versions after successfully updating all files. If the major upgrade is set to uninstall the old version before installing the new, the rollback is not available since the uninstall is already over, and the new installer will hence leave nothing installed if it fails and rolls back.

Important: For minor upgrades and for late uninstall of old version in major upgrades to work correctly, all MSI component rules must be followed 100% accurately.

When thinking about a major upgrade that uninstalls the old version after updating, you can view it as a patching operation without having the update packaged as a patch. Windows Installer will actually run a diff on the old and new version and then implement only the required changes, leaving the rest of the application untouched. Depending on the application structure and number of files, this can be significantly faster to install as well.

Late-sequenced major upgrades are also a way to prevent configuration files from being reverted to their original installation status during upgrades. This is a classic issue where config files are changed after installation, uninstalled during a major upgrade and then being reinstalled giving the impression that they are reverted, when they are actually freshly reinstalled.

I have written about Windows Installer Rollback before. Might be worth a read.

Chordophone answered 1/8, 2014 at 7:19 Comment(0)
F
1

No, this is not possible. A major upgrade uninstalls the old version before installing your new one. So when the new install fails, the old version is already removed.

Filmy answered 16/11, 2011 at 18:50 Comment(1)
No, it is possible to sequence the uninstall of the old version after the install of new files. In this scenario you can roll back to the previous version correctly (barring any other errors in the MSI).Merrow
D
1

There is a possibility but it involves changing the upgrade sequence which is not always an easy thing to achieve. You should move the RemoveExistingProducts after InstallExecute action

http://msdn.microsoft.com/en-us/library/windows/desktop/aa371197(v=vs.85).aspx

Donley answered 16/11, 2011 at 19:1 Comment(4)
This could be problematic if there are shared files. E.g.: Adobe Reader registers files in "Program Files\Common Files\Adobe\Acrobat\ActiveX\"Resolutive
I don't understand what problem you are talking about.Donley
If the previous version and the new version have common files, there could be problems if trying to copy the newer files before removing the older ones. Or if the are files registered with a browser.Resolutive
There should not be any problems regarding the file copy. Maybe you should give it a try ans see how it works for you.Donley

© 2022 - 2024 — McMap. All rights reserved.