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.

Lucian Podereu
  • 798
  • 7
  • 10
  • 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. – Stein Åsmul Aug 01 '14 at 07:06

3 Answers3

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.

Community
  • 1
  • 1
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
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.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
  • 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). – Stein Åsmul Aug 01 '14 at 07:04
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

Ciprian
  • 3,533
  • 1
  • 18
  • 22
  • This could be problematic if there are shared files. E.g.: Adobe Reader registers files in "Program Files\Common Files\Adobe\Acrobat\ActiveX\" – Lucian Podereu Nov 16 '11 at 23:59
  • I don't understand what problem you are talking about. – Ciprian Nov 17 '11 at 06:59
  • 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. – Lucian Podereu Nov 17 '11 at 09:59
  • There should not be any problems regarding the file copy. Maybe you should give it a try ans see how it works for you. – Ciprian Nov 17 '11 at 11:31