How do I prevent Windows from performing installations until a reboot occurs?
Asked Answered
E

3

2

I am testing installation scripts and must put Windows into a state that a reboot is pending from another installation. I have read how to test whether a reboot is needed. A proper way to set the need is not clear.

Enhance answered 6/4, 2018 at 14:11 Comment(1)
Installers tend to get grumpy when the HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations key is not empty.Carburize
P
1

The honest answer: I don't know for sure. There are a lot of different registry locations that indicate that a reboot is necessary. I just tried to make an ad-hoc list here: How do I reference the Reboot Pending Property in Burn (WiX). I am not sure what mechanism uses them all, but some of these reboot entries could conceivably cause further installs to be blocked.

As you know there are certain Windows Updates that manage to schedule reboot prompts that will not cease or go away and not allow further software to be installed (at least not Windows Installers). I am not familiar with the APIs used to trigger this - chances are they are Microsoft's own functions that can only be called by TrustedInstaller (Windows Modules Installer service - used to install Windows Updates- capable of replacing files protected by Windows Resource Protection ). Just a theory. If I get time tomorrow I will have another look.

There are features in group policy to disable Windows Installer by policy, but I would not go down that path if I were you. Group policy is heavy stuff and it won't prevent non-MSI installs (so far as I know). I am sure you have already found this option.

Looking at this script: Get-PendingReboot-Query, the SCCM section seems to indicate what is referred to as a "Hard Reboot" ($CCMClientSDK.IsHardRebootPending). Maybe something which indicates a reboot that will not allow anything else to be done before the reboot is done? If you have SCCM available this is the option I would investigate. Unfortunately I am not up to speed on the issue. Maybe try your luck on serverfault.com or even superuser.com where system administrators and power users lurk?

Patrilineal answered 10/4, 2018 at 1:45 Comment(1)
I'm doing SCCM work, where SCCM invokes VBScript and status is returned from that. The VBScript has to check a lot of things to return whether a reboot is pending and return the appropriate code for that, return the reboot code and actually do the reboot, return success, or return failure. Not only is there one VBScript, but another install comes after which is dependent and also uses VBScript, This will go out to a large number of machines. I'm trying to optimize testing for the best efficiency and emulating issues.Enhance
B
1

I wouldn't advise you to proceed with a reboot automatically. You should better inform the user that before going with the installation, a reboot is needed.

If you want to make sure that after the reboot (any reboot), the installer will be running, you can take advantage of the Run and RunOnce registry keys: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376977(v=vs.85).aspx

Basically, if you detect that a reboot is pending, then create those registry behind and also inform the user that he should reboot first the machine.

After reboot, the installation will be loaded automatically by Windows if you create the registries.

Bissextile answered 9/4, 2018 at 5:49 Comment(2)
Perhaps the subject line is misleading, but the poster knows how to detect a reboot when an install is being done. This is a test situation where the poster wants to set this condition to make sure that the MSI detects it.Unsaid
I read several articles regarding PendingRenameOperation. Some say if present, which is invalid. There can be delete and rename (move). Only the rename counts. The only way to know this is to parse the value and examine what the pending operations are. On my workstation for instance, security software leaves delete operations in PendingRenameOperations following each boot and this is always present in the registry. But I never have a problem installing software. Some of the better code snippets parse the information to see what it is.Enhance
P
1

The honest answer: I don't know for sure. There are a lot of different registry locations that indicate that a reboot is necessary. I just tried to make an ad-hoc list here: How do I reference the Reboot Pending Property in Burn (WiX). I am not sure what mechanism uses them all, but some of these reboot entries could conceivably cause further installs to be blocked.

As you know there are certain Windows Updates that manage to schedule reboot prompts that will not cease or go away and not allow further software to be installed (at least not Windows Installers). I am not familiar with the APIs used to trigger this - chances are they are Microsoft's own functions that can only be called by TrustedInstaller (Windows Modules Installer service - used to install Windows Updates- capable of replacing files protected by Windows Resource Protection ). Just a theory. If I get time tomorrow I will have another look.

There are features in group policy to disable Windows Installer by policy, but I would not go down that path if I were you. Group policy is heavy stuff and it won't prevent non-MSI installs (so far as I know). I am sure you have already found this option.

Looking at this script: Get-PendingReboot-Query, the SCCM section seems to indicate what is referred to as a "Hard Reboot" ($CCMClientSDK.IsHardRebootPending). Maybe something which indicates a reboot that will not allow anything else to be done before the reboot is done? If you have SCCM available this is the option I would investigate. Unfortunately I am not up to speed on the issue. Maybe try your luck on serverfault.com or even superuser.com where system administrators and power users lurk?

Patrilineal answered 10/4, 2018 at 1:45 Comment(1)
I'm doing SCCM work, where SCCM invokes VBScript and status is returned from that. The VBScript has to check a lot of things to return whether a reboot is pending and return the appropriate code for that, return the reboot code and actually do the reboot, return success, or return failure. Not only is there one VBScript, but another install comes after which is dependent and also uses VBScript, This will go out to a large number of machines. I'm trying to optimize testing for the best efficiency and emulating issues.Enhance
S
0

You can add an entry in the registry, based on which you can check for reboot. Or perform reboot.

Though I would advise you to avoid reboot, if you can. Windows installer automatically detects if the reboot is required and will indicate the same. Though you can suppress it.

There is a PendingRenameOperations registry, which is set when a reboot is required to do file updates, during an upgrade. In our product, we check for this registry key along with few other product-related registry keys - then display an message to user that reboot is required or not. If reboot is accepted by the user, then install/upgrade is terminated.

Nice article on the same: https://technet.microsoft.com/en-us/library/cc164360(v=exchg.80).aspx

Statistician answered 9/4, 2018 at 17:40 Comment(2)
Perhaps the subject line is misleading, but the poster knows how to detect a reboot when an install is being done. This is a test situation where the poster wants to set this condition to make sure that the MSI detects it.Unsaid
I read several articles regarding PendingRenameOperation. Some say if present, which is invalid. There can be delete and rename (move). Only the rename counts. The only way to know this is to parse the value and examine what the pending operations are. On my workstation for instance, security software leaves delete operations in PendingRenameOperations following each boot and this is always present in the registry. But I never have a problem installing software. Some of the better code snippets parse the information to see what it is.Enhance

© 2022 - 2024 — McMap. All rights reserved.