cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tjcemc
Level 4

How to restart Window service AFTER user "cancels" during install??

During my install, I shutdown a particular window's service. This works fine. However, if the user cancels from the installation, I would like a chance to restart the service that I earlier shutdown. There is no onCancelling even that gets fired for the install (IS11.5MP Windows). I looked at putting some code in the Cancel Frame dialog's clicked event, but once the wizardUI.doCancel(); executes, there user was already presented with a Yes/No cancel dialog and it seems like I cant execute any useful code after this - I get an illegal state exception saying the wizardservice is already shutdown

Any ideas on how to restart a windows service once the user says "Yes" to the Are you sure you want to cancel the install?

Thanks!
Labels (1)
0 Kudos
(1) Reply
CChong
Level 11 Flexeran
Level 11 Flexeran

If the cancelation by the user occurs during the progress bar, then you can use a custom product action to detect the cancelation and take appropriate action. If a component's Install Failure option is set to Cancel & Rollback, then each product action in the component is uninstalled when the user cancels the install. Thus you could stop your service in the uninstall() method of a custom product action. The only trick is to detect that the user canceled rather than ran the uninstall normally. To do this, you get the OperationState for the product action and call isCanceled(). Here is some code that does this as an example:
import com.installshield.product.ProductAction;
import com.installshield.product.ProductActionSupport;
import com.installshield.product.ProductException;
import javax.swing.*;

public class RollbackAction extends ProductAction {
/* (non-Javadoc)
* @see com.installshield.product.ProductAction#uninstall(com.installshield.product.ProductActionSupport)
*/
public void uninstall(ProductActionSupport support) throws ProductException {

if (support.getOperationState().isCanceled()) {
JOptionPane.showMessageDialog(null, "Rolling back action "+getBeanId());
// Do Rollback here
}
else {
JOptionPane.showMessageDialog(null, "Uninstalling action "+getBeanId()+ " normally.");
// Normal uninstall here or more likely no-op
}
}
}


Note that this will only work if the user cancels the install during the progress bar. On any panel in the post-install sequence, it is too late--they must run the separate uninstaller.
0 Kudos