PDA

View Full Version : Restart a service on exit



Jonathan Kay
05-26-2010, 03:06 AM
Hi,

On my final wizard dialog I have a check box the offers to restart a service when the install completes. Although I have the code (open a wait dialog, stop the service, sleep for a few seconds, start the service and close the wait dialog) I can't seem to get it to run when the 'Finish' button is clicked. If I put the code after the final 'Loop Wizard' it doesn't execute at all, and if I put it in the 'Execute Programs' section it runs before the 'Finish' dialog appears.

I don't want to have to create a separate exe to restart the service. Where must I put my code to do this, or what other changes do I need to make?

TIA,
Jon.

linder
05-26-2010, 03:13 AM
Jonathan,

Are you sure the code to start the service is executed at all? And make sure your Servive Name is correct!

As an example, see "Service.sb7" demo project.

Hope this helps.

Friedrich

linder
05-26-2010, 03:14 AM
BTW, and I would suggest to check the %_SB_ERRORCODE% return value. It should provide you with a Windows system error code if the function failed.

Friedrich

Jonathan Kay
05-26-2010, 04:22 AM
The code was ok, it was the condition checking! I was only checking 'equal to' 1 (and I'd already set the variable to 1 before the Finish dialog opened - that's why it worked eariler in the script). Of course, the Finish dialog supports multiple check boxes so I needed a check 'Equal to 1 on position' after that. My mistake.

linder
05-26-2010, 04:27 AM
Perfect! Thanks for the update!

Friedrich