1
votes

I am trying to build an MSI project, and during installation I am installing a Windows Service. If that service fails to be installed, I want to initiate rollback and cancel the installation.

I have already built an installer class and overridden the install and uninstall method. How can I initiate rollback?

1
Where do you want to initiate the rollback from? is that from a custom action? - Yossi Dahan
yes, i have an installer class that was added to the install process in the custom action, its install a windows service if that installation fails i want it to fail the whole installation and delete all files. - guyl
Try returning 1602 from your custom action: msdn.microsoft.com/en-us/library/aa369778(VS.85).aspx - rmrrm

1 Answers

1
votes

First you should know that using InstallUtil custom actions ( regardless of how documented and written about they are ) are not a good choice. Throw them away. The same goes for the Visual Studio Deployment Project that you are using to consuem your custom action.

The best solution lies in leveraging Windows Installer built-in support for creating and starting services. Use InstallShield 2010 Limited Edition ( Free ) or Windows Installer XML ( FOSS ). These tools expose the ServiceControl table which has a Wait column that allows you to teach MSI:

Wait
Leaving this field null or entering a value of 1 causes the installer to wait a maximum of 30 seconds for the service to complete before proceeding. The wait can be used to allow additional time for a critical event to return a failure error. A value of 0 in this field means to wait only until the service control manager (SCM) reports that this service is in a pending state before continuing with the installation.

ServiceControl Table