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

How to schedule a reboot at end?


1 reply to this topic

pdriley

pdriley
  • Members
  • 91 posts

Posted 22 January 2002 - 20:37

Someone must know this...

I'm trying to put a check in at the end of installers for any reboot condition: checking WININIT.INI or PendingFileRenameOperations and all combinations of [HKLM|HKCU]\...\RunOnce(Ex).  I'm using an MSI DLL written in VC++.

I'm not sure how to do it.

If I put the CA before InstallFinalize, it has to be deferred or the CAs that might cause the conditions may not have run.

If I just run MsiDoAction("ScheduleReboot") then nothing happened.

But if I return ERROR_SUCCESS_REBOOT_REQUIRED then it rolls back the installation.

Should I run a custom action after InstallFinalize?  Can I schedule a reboot at this time by returning ERROR_SUCCESS_SCHEDULE_REBOOT?  Can I access properties or do I have to use the Windows API to figure out (a) which Windows version I'm in and (b) where the Windows folder is?

Or am I doing something wrong?  Is it possible to schedule a reboot from within a deferred CA?

Help!  Someone must have done this before?


shaun

shaun
  • Members
  • 11 posts

Posted 23 January 2002 - 08:43

To reboot at end set the installer engine into this mode:

MsiSetMode(hInstall, MSIRUNMODE_REBOOTATEND, TRUE);

To Check if Reboot at End has been set Check for one of two states both RebootNow and RebootAtEnd (beacause u can have have a reboot now causing a reboot at end):

when i'm debugging i use the following checks

if (MsiGetMode(hInstall, MSIRUNMODE_REBOOTNOW))
{
   MessageBox(NULL,TEXT("Successfully set Reboot Now Mode"),TEXT("Debug"), MB_OK);
}
else
{
   MessageBox(NULL,TEXT("Reboot Now Mode not Set"),TEXT("Debug"), MB_OK);
}

if (MsiGetMode(hInstall, MSIRUNMODE_REBOOTATEND))
{
MessageBox(NULL,TEXT("Successfully set Reboot At End Mode"),TEXT("Debug"), MB_OK);
}
else
{
MessageBox(NULL,TEXT("Reboot At End Mode not Set"),TEXT("Debug"), MB_OK);
}

Take note that when u set reboot at end (or rebootnow) using MsiSEtMode then the installer wont put in anything under RunOnce to restart the installation after the reboot has completed.