views:

75

answers:

2

Does anyone know how to make InstallAware do a rollback of a database when the user clicks 'Cancel'? Unlike InstallShield I'm not seeing any way to specify when individual scripts run.

A: 

You sure this isn't just done auto-magically? InstallAware seems to do some funky things at times, and I wonder if they do what amounts to a rollback in some weird way.

Cory R. King
I haven't tried it but I would seriously doubt it just automatically starts deleting stuff from the database without being told to.
Max Schmeling
I'd give it a shot in a virtual machine. When I used InstallAware, I always assumed it would clean house automagically. The docs never mentioned the need to tell it to cleanup either--though it does mention cleanup, but only in the context of your installer installing other MSI's.
Cory R. King
A: 

I don't think InstallAware would be able to rollback a database transaction. I didn't see any intrinsic support for SQL Server rollbacks in their MS SQL Server command. You would need to code your own rollback script, if that is possible.

There is usually a section in the MSICode that has an IF block if the user cancels the installation during the initial dialogs. It looks something like this

if variable WIZARD Equals CANCEL
    Terminate Installation
end

This occurs before the Windows Installer engine actually performs the installation. If you have not executed your database scripts, then no action is required. If you have applied database scripts before this point, you will need to supply a rollback script (if possible) and execute it in that block, but before Terminate Installation.

If you cancel the installation while install, you'll have another shot of rolling back your changes. When the user presses the cancel button while the installation process is running (i.e. after the user has made any selections), the InstallAware variable SUCCESS will be set to CANCEL. You can check for that condition and execute your rollback script. There is usually a block of code that does various things based on the value of SUCCESS, you can add your code there.

You could always make your SQL script the last command executed by InstallAware as part of the installation. That would eliminate the need to handle the cancellation.

Chris Miller