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

Author: BitRock Support       Date: November 21, 2008 05:29       Tags: Actions
Action list
Features
Tips
Uninstallation

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>

 

Back You should login to comment

 

You are
currently not
logged in.

 Log in 

or

Sign up