Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Abort Installation using CA Return Code


3 replies to this topic

Phil George

Phil George
  • Members
  • 1 posts

Posted 27 February 2002 - 15:59

Hi All

I have a simple msi that runs an exe using a CA (CA is set to deferred mode). My exe displays a UI that asks if the user wishes to do some tasks. If the user clicks NO or CANCEL, I want to be able to abort the install, without it adding the msi to Add/Remove Programs.

At the mo I've tried returning -1, -2, -3, 1, 2 etc and all I get is "Internal Error 2744" which doesn't look very pretty for the user!

Is there a number that will stop it installing (aborting/rolling back) or can I disable this error msgbox, and just let the msi abort. I don't wanna use scripts if poss...

Any help much appreciated...

Many thanks

Phil (pageorge@rm.com)



Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 27 February 2002 - 16:23

You shoud return with
ERROR_INSTALL_FAILURE
which is 1603

The definitions of your CA should be set to halt on errors.

You may want to use MsiProcessMessage with INSTALLMESSAGE_FATALEXIT to log the fault etc.


WilliamB

WilliamB
  • Members
  • 1 posts

Posted 27 February 2002 - 16:25

According to the Installer documentation:
Custom actions that are executable files must return a value of 0 for success. The installer interprets any other return value as failure. To ignore return values set the msidbCustomActionTypeContinue bit flag in the Type field of the CustomAction table.

To get around this, I suggest you create two defered custom actions, one placed in the sequence prior to your executable custom action and one placed after.

The first custom action should create a named file mapping (backed by the page file) and simply return success. When your executable is finished, it should open this named section, store it's desired result code in it and then return zero to the installer. The second custom action will then open the mapping object, read the return code from the executable and return it to the installer.

Using this method, you should be able to return ERROR_INSTALL_FAILURE from the executable (albeit indirectly) causing the installation to rollback and display the failed dialog from the UI sequence. If you don't want the install to rollback, you can return ERROR_NO_MORE_ITEMS, which will cause the installation to continue, but skip all the remaining actions in the generated script.


Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 27 February 2002 - 16:36

Sorry I misread the original question.  My reply applies to DLLs only.  Williams approach seems worth trying.  Best practice suggests you avoid user interface in the execute sequence.  If you can avoid it by asking the question earlier (In the UI sequence) then you should.