PDA

View Full Version : How to know user click "cancel" button during uninstall?



Simon_Yang
12-17-2008, 02:58 PM
I had a basic MSI project. When user uninstall from ""Add or Remove Programs", I will use a custom action to reset some settings. Howerver, if user click "cancal" button, I want to use another custom action to set those settings back.

The problem is how can I know user clicked "cancel" button.


Anyone has idea about that? Thanks!

RobertDickau
12-17-2008, 03:34 PM
You'll want to investigate rollback custom actions, a type of custom action intended to reverse the effects of deferred actions during a failed or canceled installation or uninstallation.

(Commit actions can clean up temporary data saved for the possible use of a rollback action, but first things first.)

Simon_Yang
12-17-2008, 07:18 PM
Hi Thanks for reply!

I just tried to use rollbeck custom action. What I did is first , I created custom action named as "StopService" which will stop a service. I set it as immediate execution. Then I created another custom action named as "StartService" which will start the service. I set it as Rollback Exection. In the sequences, StartService is behind StopService.

I hope, when I uninstalled the product, StopService will be called first. Then, if I clicked cancel button, StartServoce will be called. It can just reverse what StopService did.

In fact, when I clicked cancel button during, StartService was not be called.

Can anyone tell me why? Thanks a lot!!!

RobertDickau
12-17-2008, 07:33 PM
Some general points:

Only deferred actions can be rolled back (which makes sense, since only deferred actions should make system changes). Immediate actions should set properties and query the system, but not touch the target machine.

A rollback action should be placed in the sequences before the action it rolls back.

Not a technical issue, but there are standard actions called StartServices and StopServices, so you might slightly rename yours to avoid confusion.

If all else fails, creating an MSI log file should help understand whether/why actions are or are not being executed.

Simon_Yang
12-17-2008, 07:37 PM
Thanks a lot!!!