Hello Andre,
As promised, here is my followup after further investigating this.
It looks like I was indeed right about the reason why this is happening.
Basically, the scheduled task that is created to restart the setup after the reboot is not removed in due time (it is removed after the user presses on the
"Finish" button).
The solution to this would be to add a little bit of delay to the reboot action.
Unfortunately, the only way to achieve this would be through another custom action, since you can not add a delay to the
"Set property" custom action.
The custom action should also be able to run
asynchronously (the setup should not wait for it).
In the end, here is what I've came up with: a small .EXE that display a messagebox and then proceed to perform the reboot through the
"shutdown.exe" OS tool. The easiest way of doing this would have been through a script, but unfortunately script custom actions can not be run asynchronously.
The .EXE can be written in any language you want. I will provide in the following lines how I have created one in C#, perhaps that will help you:
Code: Select all
namespace RebootMachine
{
class Program
{
static void Main(string[] args)
{
// Initialize the variables we pass to the MessageBox.Show method
string caption = "Reboot the machine";
string message = "Are you sure you want to reboot the machine?";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxIcon icon = MessageBoxIcon.Question;
DialogResult result;
result = MessageBox.Show(message, caption, buttons, icon);
if (result == DialogResult.Yes)
{
System.Diagnostics.Process.Start("shutdown.exe", "/r /t 5 /c \" \"");
}
}
}
}
As you can see, we run the "shutdown.exe" tool that comes by default with any Windows OS. The parameters we pass mean:
/r --> shutdown and then restart
/t 5 --> wait 5 seconds before rebooting (the delay we discussed earlier)
/c " " --> usually, a prompt will appear stating that "This machine will be rebooted in less than a minute" or something similar depending on the time we've set. We use this parameter to avoid that.
Now, to implement this in Advanced Installer, add the .EXE in the
"Files and Folders" page. After doing so, add a "Launch File" custom action,
without sequence that launches the .EXE. For this custom aciton, uncheck the
"Wait for custom action to finish before proceeding" &
"Wait for return code at the end of the sequence" options.
Proceed as before by scheduling the custom action as a
"Published Event" and conditioning it based on the checkbox selection.
Hope this will help!
Best regards,
Catalin