Installer couldn't prompt to reboot the system after installing prerequisite - Advanced Installer Community
lustoro
Posts: 3
Joined: Tue Dec 03, 2019 9:50 am

Installer couldn't prompt to reboot the system after installing prerequisite

Hi,
I want to restart the system after installing .NET Framework 4.7.2 as a prerequisite and abort installation in a case if user didn't restart machine after installing prereq.
For that I've Added .NET Framework 4.7.2 as a Pre-Install prereq from Predefined Prerequisites list and checked "Reboot system after installing this prerequisite" checkbox and choosed "Only if prerequisite installed successfully" option from prereq properties page. From "Setup Files" tab I've removed /q /norestart command. And also in "Install Parameters" page, for "Reboot behavior" I've selected the value "Prompt for Reboot when required", and unchecked "Perform the reboot if required without showing any prompts" checkbox (those are default values). But after installing .NET Framework 4.7.2 prereq, installer didn't prompt to reboot machine.
Could someone please tell me why doesn't it work.

Regards,
Lusine
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer couldn't prompt to reboot the system after installing prerequisite

Hello Lusine and welcome to Advanced Installer forums,

First of all, please allow me to explain how we do the prerequisite checks. We only do two checks, and those are:

-- This is related to the condition that is defined in the "Install Conditions" tab of the prerequisite --> "Install Conditions" section.

1. first, we check this condition before the prerequisite is installed. If the condition is false ==> it means the prerequisite is not installed ==> we proceed with the installation

2. second, we check this condition after the prerequisite was installed. If the condition is true ==> it means that the prerequisite was installed ==> we proceed further. If the condition is false, we abort the installation.

Now, .NET Framework, in general, is quite a special package. As you can see, the condition that we evaluate is:

HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release

should be 461813 or above.

So, basically:

- we check for that registry entry before installing .NET Framework. We see that the key does not exist or has a lower value than the one specified ==> we proceed with the installation

- after the installation, we check once again for it. Here comes the special part about .NET Framework:

That registry key, specified above, is only written after the reboot - I can't tell you why, unfortunately. With that being said, a must so you can install .NET Framework as a prerequisite is to have the "Continue with the main installation even if the prerequisite is not installed" ("Properties" tab). The reason behind this is the above explanation. Basically, Advanced Installer will check for that and will fail the installation, because the registry entry is not written, due to the fact that the reboot did not happen.

Now, your condition for reboot was:

"Reboot system after installing this prerequisite" ==> "Only if prerequisite was installed successfully"

Basically, here, the reboot is not happening because, when the condition is checked, the registries are not written, therefore the setup interprets the installation as failed ==> the reboot prompt is not happening.

Fortunately, .NET Framework has its own command line switches which can be used. For instance, the "/promptrestart" switch will prompt the user for a restart in case one is needed. What you need to do here is to go to "Setup Files" tab and set the "Install Command Lines" field for "Full UI" and "Basic UI" to "/promptrestart".
promptrestart.png
promptrestart.png (116.63 KiB) Viewed 4772 times

This way, the prerequisite will prompt for restart after it is installed.

In addition to that, please remove the "Reboot system after installing this prerequisite" option from "Properties" tab.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lustoro
Posts: 3
Joined: Tue Dec 03, 2019 9:50 am

Re: Installer couldn't prompt to reboot the system after installing prerequisite

Hi Catalin,
Thanks for your detailed and helpful explanation. )))
Solution suggested by you prompts user that user need to restart system and asks the user whether to restart the system now or later. In a case if user choose restart later, installation process continues. In my case I don't need to continue installation process in a case if user choosed restart later option. How I can abort installation process in a case if user choosed restart later option? )))

Regards,
Lusine
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer couldn't prompt to reboot the system after installing prerequisite

Hello Lusine,

Unfortunately, I am afraid that may not be possible.

In order to achieve that, you would need some sort of response code based on user decision (i.e. if user press restart, return X, else return Y.), which I'm afraid the .NET Framework Setup does not offer.

If .NET Framework would return something in those cases presented above, it would be possible to achieve what you want. For instance, you could save the return value in a property ("Prerequisites" page --> "Setup Files" tab --> "Save return value in this property" field)and then use that property as a condition for a custom action that fails the whole setup.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer couldn't prompt to reboot the system after installing prerequisite

Hello Lusine,

A followup to my last thread:

I think I have found a solution in which you can fail the installation if the user does not choose to restart.

To do so, you can go to "Prerequisites" page --> "Properties" tab --> and uncheck the "Continue with main installation even if prerequisite is not installed"

Based on the explanation from my first thread, the reason why this will fail is the second check we automatically do will fail.

Basically: the prerequisite is installed ==> the user is prompted for restart ==> he chooses no ==> we perform the second check ==> because the restart was not done, the registry keys are not updated ==> the prerequisite will appear as uninstalled, even if it is installed ==> the prerequisite appearing as uninstalled means a failure return code ==> the main installation will fail.

A message box will be spawned stating that the prerequisite was not correctly installed and then the main installation will fail.

To be fully honest with you, I do not really think this is a good solution, but if you really need to fail the installation if the user does not restart, I'm afraid that this is the only one, at least for your scenario.

Another solution would be to have the "Reboot system after installing this prerequisite" set to "Always" in the "Properties" tab, but unfortunately this does not cover the fact that you need the user to be prompted.

Hope this helps somehow.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lustoro
Posts: 3
Joined: Tue Dec 03, 2019 9:50 am

Re: Installer couldn't prompt to reboot the system after installing prerequisite

Hello Catalin,
Thank you for your explanations and suggestions, I will try the solution which you suggested on last thread. )))

Regards,
Lusine
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer couldn't prompt to reboot the system after installing prerequisite

You are always welcome, Lusine.

Hope this will help.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”