How can I get the return code from a CustomAction?

fredley picture fredley · Apr 19, 2012 · Viewed 7.2k times · Source

I have the following CustomAction in my project:

<CustomAction Id="InstallDriver"
                  Return="check"
                  Execute="deferred"
                  Impersonate="no"
                  FileKey="FileDriverInst"
                  ExeCommand="-install" />

<InstallExecuteSequence>
    <Custom Action="InstallDriver" Before="InstallServices" />
</InstallExecuteSequence>

The program that installs the driver produces useful return codes, for example if the installation failed because the system needs to be restarted following a previous driver uninstall.

Currently if anything other than success is returned, I get a dialog saying 'A program run as part of the setup did not finish as expected.' and the installation fails. This is not optimal.

How can I get and handle return codes?

Answer

cosmin picture cosmin · Apr 20, 2012

Windows Installer doesn't support handling custom action return values.

For an EXE custom action a non-zero return value is interpreted as an error and the installation stops. Only a win32 DLL or VBScript custom action can change the installation behavior through its return code, but it's still very limited.

If you want to reboot the machine after install, you can set the REBOOT property.