I have a custom action that runs a 3rd party exe that installs a device driver.
It may return an error code of -17 if the system needs to be rebooted.
I would like to catch this error code and set the REBOOT flag appropriately.
How do I do this?
Unfortunately Windows Installer does not support a way of handling the return codes of the custom actions (they are handled automatically). Therefore, what you need can be done by handling the return code of the third party EXE inside a custom action.
In a C++ DLL you can use the ShellExecuteEx function to launch the EXE and the GetExitCodeProcess function to get its return code. If the return code is -17, you can use the MsiSetProperty function to set the REBOOT property to "Force".
From within my Custom Action DLL, how do I find out where the application has been installed to?
I need to do a ShellExecute on an exe that has been copied to the APPDIR.
Inside the custom action you can use the MsiGetProperty function to get the value of APPDIR. To this value you can append the name of the EXE you want to launch in order to obtain a complete file path.
I'm seeing a strange problem when I try to set the REBOOT property:
res = ::MsiSetProperty(hInstall, _T("REBOOT"), _T("Force"));
res is set to 6 (ERROR_INVALID_HANDLE)
Interestingly, hInstall is also 6 when the entrypoint in the DLL is called.
This could be a coincidence, but MsiSetProperty should not be returning 6.
What am I doing wrong?
Please make sure that your custom action is written correctly. The User Guide contains some sample code which may help you. Basically, the function which is being called from the MSI should look like this:
Since the handle is the same in the entire custom action ("hInstall"), most likely there is a problem with the way you call the custom action. Can you please send us the AIP (project) file you are using to support at advancedinstaller dot com so we can investigate it?
FOLLOW US
Get the latest news in Application Packaging