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

Signal a reboot from a deferred custom action


8 replies to this topic

mmorris

mmorris
  • Members
  • 17 posts

Posted 23 June 2003 - 23:50

How can I schedule a reboot from within a deferred custom action?

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!
Mike Morris

paracha3

paracha3
  • Members
  • 19 posts

Posted 27 June 2003 - 02:19

have you tried calling MsiSetMode from your Def CA? with MSIRUNMODE_REBOOTATEND as an agrument?

Don't know why you need the database handle for?

paracha3

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 27 June 2003 - 09:41

In a deferred CA, the database handle is invalid for almost all access. As a workaround, remove the Deferred flag, and schedule your action after InstallFinalize.

paracha3

paracha3
  • Members
  • 19 posts

Posted 01 July 2003 - 05:38

you don't need database handle for MsiSetMode function. Just hInstall would do it

paracha3

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 01 July 2003 - 09:00

You missed the point: hInstall is not valid during Deferred CAs.
Almost every function will return ERROR_INVALID_HANDLE.

See "Obtaining Context Information for Deferred Execution Custom Actions" in Msi.chm.

paracha3

paracha3
  • Members
  • 19 posts

Posted 05 July 2003 - 06:34

hum.... but i remember i called MsiGetProperty from Defered CA once and that seem to take the hInstall handle and return me "CustomActionData" property!!! may be that func is exception to that?!?! wink.gif

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 05 July 2003 - 10:07

You can only call the following functions in a deferred custom action:

  • MsiGetProperty
  • MsiFormatRecord
  • MsiGetMode
  • MsiGetLanguage
  • MsiProcessMessage

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.


sk_jain2000

sk_jain2000
  • Members
  • 8 posts

Posted 11 July 2003 - 14:00

CA -> Set Property ->ForcedReboot
Property Value: Forced
Sequence: Normal Execute Immediate /Deferred
Location: Before InstallFinalize




mmorris

mmorris
  • Members
  • 17 posts

Posted 29 August 2003 - 21:56

Thanks for the suggestions.

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!

biggrin.gif
Mike Morris