Signal a reboot from a deferred custom action
Posted 23 June 2003 - 23:50
I have a Windows Installer dll custom action that I made deferred execution because it changes the system. My installer doesn't know if a reboot is necessary until this custom action runs. It would be easy if I could just set a property that is a condition on the ScheduleReboot action, but a deferred custom action can't write to the installer database. Attempting to do so returns an "Invalid handle" error.
What are my options here?
Do I have to change my system-changing custom action into immediate execution? This would seemingly solve the problem, but it's not the "right" way to do things.
I also tried setting an environment variable in my CA that is then used as a condition on ScheduleReboot. I can't get this to work because the installer process doesn't see the new environment variable unless I kill it and restart.
Any help would be greatly appreciated!
Posted 27 June 2003 - 02:19
Don't know why you need the database handle for?
Posted 27 June 2003 - 09:41
Posted 01 July 2003 - 05:38
Posted 01 July 2003 - 09:00
Almost every function will return ERROR_INVALID_HANDLE.
See "Obtaining Context Information for Deferred Execution Custom Actions" in Msi.chm.
Posted 05 July 2003 - 06:34
Posted 05 July 2003 - 10:07
You cannot call MsiSetMode. You can't even detect a scheduled reboot using MsiGetMode.
I don't know of a direct way to schedule a reboot from a deferred action. You would either have to detect whether a reboot is required (e.g. locked files) beforehand, in an immediate action, or your deferred action could store information somewhere (registry, temp file) where it can later be picked up by an immediate action which would schedule the reboot.
Posted 11 July 2003 - 14:00
Property Value: Forced
Sequence: Normal Execute Immediate /Deferred
Location: Before InstallFinalize
Posted 29 August 2003 - 21:56
I solved this problem using the following technique:
1) If my deferred custom action decides that a reboot is needed, it creates a dummy file in %TMP%.
2) I created a new immediate custom action "CheckReboot" that checks for the existence of this file. If the file exists, CheckReboot sets a property "NEEDREBOOT".
The key here is to place CheckReboot after InstallFinalize. This ensures that CheckReboot will get called AFTER the deferred custom action in step 1. This also means that CheckReboot will be able to use the MSIHANDLE to set the property.
3) Place the built-in action ScheduleReboot after CheckReboot with NEEDREBOOT as a condition.
This works beautifully!