cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hjsunj
Level 6

How to reboot machine?

I have customize a SdFinishReboot dialog, and use DefineDialog to show it like the following code:

function RunSdFinishReboot()
string szDialogName, szString;
HWND hMain;
number nResult, nControl, retVal, ctrlState;
BOOL bDone;
begin
szDialogName = "SdFinishReboot";
// see if the installer window already exists
hMain = GetWindowHandle( HWND_INSTALL );
nResult = DefineDialog(szDialogName, NULL, "", SDFINISHREBOOT_DIALOGID, "", NULL, HWND_INSTALL, DLG_MSG_STANDARD | DLG_CENTERED);
// Check to see if dialog creation failed
if (nResult < 0) then
if (hMain < 0 ) then
abort;
endif;
endif;
// show it
SetForegroundWindow(hMain);

bDone = FALSE;

while (!bDone)
nControl = WaitOnDialog(szDialogName);
switch (nControl)
case DLG_INIT:
SetDialogFont(szDialogName,"",0,0);
// finish btn
LoadStringFromStringTable("IDS__DialogId_12031_ControlId_1",szString);
CtrlSetText(szDialogName,1,szString);
// IS complete
LoadStringFromStringTable("IDS__DialogId_12031_ControlId_50",szString);
CtrlSetText(szDialogName,50,szString);
// description
LoadStringFromStringTable("IDS__DialogId_12031_ControlId_711",szString);
// replace the %P
TextSub.Value("PRODUCTNAME") = IFX_PRODUCT_NAME;
TextSub.Substitute(szString);
CtrlSetText(szDialogName,711,szString);
// remove disks and press finish text
LoadStringFromStringTable("IDS__DialogId_12031_ControlId_712",szString);
CtrlSetText(szDialogName,712,szString);
// yes reboot
LoadStringFromStringTable("IDS__DialogId_12031_ControlId_502",szString);
CtrlSetText(szDialogName,502,szString);
// no dont reboot
LoadStringFromStringTable("IDS__DialogId_12031_ControlId_503",szString);
CtrlSetText(szDialogName,503,szString);
case 1: // finish button
// get "yes reboot now" state
ctrlState = CtrlGetState(szDialogName,502);
if (ctrlState == BUTTON_CHECKED) then
retVal = WILL_REBOOT;
else
retVal = NEXT;
endif;

bDone = TRUE;
endswitch;
endwhile;
EndDialog(szDialogName);
ReleaseDialog(szDialogName);
return retVal;
end;

Note that the bold code above, I can detect the user check to reboot checkbox, But I don't know how to reboot the system, should I use the following function?

system(SYS_BOOTMACHINE);
Labels (1)
0 Kudos
(5) Replies
Kelter
Level 10

Set the REBOOT Property to "force"

See the MS documentation on the REBOOT Property for more information.
0 Kudos
hjsunj
Level 6

Hi,Kelter

I've added the following code into the function OnFirstUIAfter()

function OnFirstUIAfter()
...
begin
...
//MsiDoAction(ISMSI_HANDLE, "ForeceReboot");
//MsiSetMode(ISMSI_HANDLE, MSIRUNMODE_REBOOTNOW, TRUE);
MsiSetProperty(ISMSI_HANDLE, "REBOOT", "Force");
end;

But it didn't work, no reboot happened.

I also used the MsiDoAction(ISMSI_HANDLE, "ForeceReboot") to replace MsiSetProperty(ISMSI_HANDLE, "REBOOT", "Force"), but this function returns ERROR_FUNCTION_NOT_CALLED

I also use MsiSetMode(ISMSI_HANDLE, MSIRUNMODE_REBOOTNOW, TRUE), and then a dialog prompted, which says:
The installer must restart your system before configuration of [2] can continue. Click Yes to restart now or No if you plan to restart later.
But after clicking Yes, no reboot happened.

Did I do something wrong?
Any advice would be appreciated.
0 Kudos
Kelter
Level 10

You would probably want to use ScheduleReboot instead of ForceReboot. (See topic: "System Reboots")

Otherwise, I'm confused. Have you checked out the log to see what might have gone wrong?
0 Kudos
hjsunj
Level 6

Hi, Kelter!
I've used MsiDoAction(ISMSI_HANDLE, "ScheduleReboot"); in then function
OnFirstUIAfter().
And the log file as follows:

...
Action ended 19:57:32: CostFinalize. Return value 1.
MSI (c) (BC:B8) [19:57:32:270]: Note: 1: 2205 2: 3: ISAlias
MSI (c) (BC:B8) [19:57:32:270]: Note: 1: 2228 2: 3: ISAlias 4: SELECT * FROM ISAlias
MSI (c) (BC:6C) [19:57:32:286]: Entering MsiProvideComponentFromDescriptor. Descriptor: NocEDITzn?0exBp'6!7bCore>M5KDYSUnf(HA*L[xeX)y, PathBuf: 1DFEEA4, pcchPathBuf: 1DFEEA0, pcchArgsOffset: 1DFEE00
MSI (c) (BC:6C) [19:57:32:286]: MsiProvideComponentFromDescriptor called for component {997FA962-E067-11D1-9396-00A0C90F27F9}: returning harcoded oleaut32.dll value
MSI (c) (BC:6C) [19:57:32:286]: MsiProvideComponentFromDescriptor is returning: 0
MSI (c) (BC:B8) [19:57:33:161]: Doing action: ScheduleReboot
Action 19:57:33: ScheduleReboot.
Action start 19:57:33: ScheduleReboot.
Action ended 19:57:33: ScheduleReboot. Return value 1.

=== Verbose logging stopped: 2008-4-15 19:57:33 ===


You can see that the ScheduleReboot run,and return value 1. Does value 1 mean success? If it mean success, why did reboot not happen?
0 Kudos
Kelter
Level 10

I'm befuddled. I haven't spent a whole lot of time debugging InstallScript MSI projects, but as far as any rebooting is concerned, that's all i've ever really needed to do (or the equivalent in Basic MSI...)

I'm baffled as well. Anybody else?

Sorry, I'd set up a text project and try to figure it out, but things are extremely busy this week.
0 Kudos