How can I abort the uninstallation if a pre-uninstall action fails?

asked 14 Sep '11, 04:43

Jake's gravatar image

Jake ♦♦
826222226235
accept rate: 98%


If an action inside the <preUninstallationActionList> fails, you will notice the uninstallation continues. In the same fashion, if you execute a <throwError> action during the uninstallation it will have no effect.

This behavior is being caused by a "feature": uninstallers ignore errors in case any action fails, including the <throwError> action (which will ignored by the uninstaller). The reasoning behind this behavior is that unlike an installer, the uninstaller should never fail (for example, because the user may have already manually deleted some files).

One possible workaround you can use to abort the uninstallation is to combine <showWarning> and <exit> actions to emulate the behavior of <throwError>. The following snippet combines both actions inside an <actionGroup>:

<project>
    ...
    <preUninstallationActionList>
        <actionGroup>
            <!-- Executing two actions as if they were one -->
            <actionList>
                <showWarning>
                    <text>InstallBuilder is running, aborting installation.</text>
                </showWarning>
                <exit></exit>
            </actionList>
            <ruleList>
                <!-- This rule is currently supported for Linux, Windows and OSX only. Checking if "builder" is running will not work for Windows -->
                <processTest>
                    <name>builder</name>
                </processTest>
            </ruleList>
        </actionGroup>
    </preUninstallationActionList>
    ...
</project>
link

answered 14 Sep '11, 04:45

Jake's gravatar image

Jake ♦♦
826222226235
accept rate: 98%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×13
×11
×3

Asked: 14 Sep '11, 04:43

Seen: 1,126 times

Last updated: 14 Sep '11, 04:45