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

Using ScheduleReboot and getting the condition right


Best Answer deramor , 22 August 2013 - 20:25

Problem solved.  =! does not mean the same thing as !=.  Who knew?!

Go to the full post


1 reply to this topic

deramor

deramor
  • Full Members
  • 187 posts

Posted 22 August 2013 - 18:51

Hello-

 

My company has written a service that grabs large chunks of memory (up to 1Gig) to use for data transfers.  My installer needs to start this service and detect a failure to start.  A failure to start indicates that memory is fragmented and the computer must be rebooted.

 

In order to alert the user to this failure condition I have done the following:

 

Created a public property CUSTOM_REBOOT and set it to 0.

Created a custom action running install script code.  It is Immediate and scheduled after InstallFinalize.

 

This CA fires correctly since I can watch the system memory usage change.

 

In the code I have the following:

function Restart_MMS(hMSI)
NUMBER nvServiceState;
begin

    ServiceStopService("MemoryService");
    ServiceStartService("MemoryService","");
    Delay(2);//wait for 2 seconds before looking at the service state.
    // The MMS will enter the started state and wait for 1 second before closing if it can't get the
    // required amount of RAM thus giving us a false reading
    ServiceGetServiceState ("MemoryService", nvServiceState);
    
    if(nvServiceState =! SERVICE_RUNNING) then //the service did not start.  Need to reboot.
        MsiSetProperty(hMSI, "CUSTOM_REBOOT", "1");
    endif;

end;

 

Since the CA is outside of the InstallInitialize - InstallFinalize sequence, I assume I can access public properties directly without using CustomActionData.

 

I then modified ScheduleReboot built in CA (comes right after the one I wrote) to have the condition:

ISSCHEDULEREBOOT OR CUSTOM_REBOOT="1"

 

This condition is always false.

 

Am I doing something obviously wrong here?  Am I testing for the value in the reboot condition correctly?

 

The behavior I expect would be if the CA detects the service is not SERVICE_RUNNING, It will set the property CUSTOM_REBOOT to 1.  This will in turn trigger the reboot to get scheduled.

 

Any thoughts?



deramor

deramor
  • Full Members
  • 187 posts

Posted 22 August 2013 - 20:25   Best Answer

Problem solved.  =! does not mean the same thing as !=.  Who knew?!