Skip to main content

Reboot Pending Prompt - Autofix

Overview

This script acts as the remediation (Autofix) component of the "Reboot Pending Prompt" solution. It is triggered automatically when the Detection script determines that a reboot is necessary and conditions are right to interrupt the user.

Since RMM scripts run in the background (Session 0) and cannot normally show windows to the user, this script utilizes a temporary Scheduled Task to bypass this limitation. It launches a branded GUI utility (Prompter.exe) inside the active user's session. Depending on how many times the user has already postponed the reboot, the script will either present a "Yes/No" deferral option or a "Final Warning" that enforces the reboot after a few minutes.

Install-In-Progress Protection

Before rebooting an unattended machine (no user logged in, or locked screen with the forced reboot threshold reached), the script checks whether software or updates are currently being installed. If an install is detected, the script exits cleanly without rebooting. It will try again on the next cycle after the install finishes.

This prevents the machine from restarting in the middle of a Windows Update, application installer, or feature upgrade.

The following processes and signals are checked:

SignalWhat It Means
TiWorker.exeWindows Update is actively installing an update
wusa.exeA standalone Windows Update package is being installed
SetupHost.exeA Windows Feature Update is in progress
setup.exeA general installer is running
MoUsoCoreWorker.exeThe Windows Update orchestrator is doing background work
Windows10Upgrader.exeA feature upgrade using the Windows Update Agent is running
winget.exe (active)Windows Package Manager is installing or updating software (only when actively using CPU)
BITS transfer jobsBackground downloads are in progress (used by Windows Update and other services)
MSI mutex heldAn MSI installer package is currently running

Note: This check only blocks unattended reboots. If a user clicks "Yes" to reboot, the reboot happens immediately. The user made a conscious choice to restart.

Sample Run

Note:

  • It is not recommended to run this script manually. The script is designed for the Autofix script of Reboot Pending Prompt - Windows Workstation compound condition.
  • Prompter requires '.NET Desktop Runtime 10.0' to run. If missing, the script automatically downloads and installs it silently.

Dependencies

Custom Fields

Custom FieldDefaultExampleDescription
cPVAL Reboot Prompt Count45Max deferrals allowed before a forced reboot.
cPVAL Reboot Prompt Duration Between Prompt42Minimum hours to wait between prompts. Used for message display text only in this script.
cPVAL Reboot Prompt TitleUpdates Installed - Reboot RequiredIT Dept: Important UpdatesTitle of the GUI window.
cPVAL Reboot Prompt MessageAn update has been installed on your computer. Would you like to restart now to complete the installation of updates? You have {X} prompt(s) remaining before a forced reboot. Next prompt will be sent in {Y} hours.We installed security patches. Resulting Prompt: We installed security patches. Would you like to restart now? You have {X} prompt(s) remaining before a forced reboot.Custom message body. The script automatically appends the question and remaining count to whatever text you provide. Avoid using single quotation marks (') in the message. Use regular quotes (") if needed.
cPVAL Final Prompt MessageAn update has been installed on your computer. This is the final prompt before your computer will automatically restart to complete the installation of updates. Please save your work. Your computer will be restarted after {X} minute(s) after you acknowledge this prompt.Deferrals exhausted. Resulting Prompt: Deferrals exhausted. This is the final prompt before your computer will automatically restart. Your computer will be restarted after {X} minute(s) after you acknowledge this prompt.Message displayed when no deferrals remain. The script automatically appends the reboot warning and timer to your text. Avoid using single quotation marks (') in the message. Use regular quotes (") if needed.
cPVAL Reboot Prompt Timeout30060Time in seconds before a "Warning" prompt closes automatically (defaults to deferral).
cPVAL Final Prompt Timeout900120Time in seconds before a "Final" prompt closes automatically (defaults to forced reboot).
cPVAL Final Prompt Reboot Delay Minutes510Grace period (in minutes) after final acknowledgment before the forced reboot occurs.
cPVAL Reboot Prompt Header ImageC:\Logos\header.png or https://example.com/logo.pngLocal file path or URL for the header image.
cPVAL Reboot Prompt Icon ImageC:\Logos\icon.icoLocal file path or URL for the icon image.
cPVAL Reboot Prompt ThemeDarkLightUI Theme: "Dark" or "Light".
cPVAL Reboot if Not Logged InDisableEnableForces reboot immediately if no user session is active.
cPVAL Reboot Prompt Suppress Time Window1800-080024-hour time range (HHmm-HHmm) to suppress prompts. Leave blank to disable.
cPVAL Max Missed Prompts Before Force03Number of consecutive missed prompts before forcing a reboot without showing the GUI. Set to 0 to disable.
cPVAL Last Prompted2024-05-20 14:30:00Updated to current timestamp if user defers. Updated by script.
cPVAL Times Prompted2Incremented by 1 if user defers. Resets to 0 on Reboot. Updated by script.
cPVAL Pending RebootFalseSet to False upon successful reboot initiation. Updated by script.
cPVAL Consecutive Missed Prompts2Tracks consecutive missed prompts. Managed by the Detection script and reset on reboot.
cPVAL First Missed Prompt Time2024-05-20 14:30:00Records when the current missed-prompt streak started. Managed by the Detection script and reset on reboot.

Default Values

The script includes built-in defaults when related custom fields are blank or not set:

SettingVariable NameDefault Value
Reboot Prompt Title$defaultPromptTitleUpdates Installed - Reboot Required
Reboot Prompt Count$defaultRegularPromptCount4
Final Prompt Reboot Delay Minutes$defaultFinalRebootDelayMinutes5
Reboot Prompt Duration Between Prompt$defaultDurationBetweenPromptsHours4
Reboot Prompt Timeout$defaultRegularPromptTimeoutSeconds300
Final Prompt Timeout$defaultFinalPromptTimeoutSeconds900
Reboot Prompt Theme$defaultPromptThemeDark
Reboot Prompt Header Image$defaultHeaderImageBlank
Reboot Prompt Icon Image$defaultIconImageBlank
Reboot Prompt Suppress Time Window$defaultSuppressTimeWindowBlank (disabled)
Max Missed Prompts Before Force$defaultMaxMissedPromptsBeforeForce0 (disabled)
Reboot if Not Logged In$defaultRebootIfNotLoggedInDisable
Reboot Prompt Message$defaultRegularMessageBuilt-in standard reboot prompt message
Final Prompt Message$defaultFinalMessageBuilt-in final warning message

Do not change these values directly in the script. The PowerShell script is code-signed, and editing the defaults will break the signature. If you need different built-in defaults, send a request to ProVal.

Automation Setup/Import

Automation Configuration

Output

  • Activity Details: Logs the interaction result (e.g., "User declined reboot", "User opted to reboot", or "Final prompt acknowledged").
  • Custom Fields: Updates cPVAL Last Prompted and increments cPVAL Times Prompted if the user defers. Resets cPVAL Pending Reboot, cPVAL Last Prompted, cPVAL Times Prompted, cPVAL Consecutive Missed Prompts, and cPVAL First Missed Prompt Time if the reboot is initiated.
  • User Prompt

Prompt Progression & Message Examples

The script calculates the number of remaining prompts by subtracting the times the user has already been prompted (cPVAL Times Prompted) from the maximum allowed deferrals (cPVAL Reboot Prompt Count). The user sees this count in every message they receive.

Understanding the Count

The first prompt displays the same number as cPVAL Reboot Prompt Count (e.g., 4) because this represents the total "deferrals" available. However, an additional final mandatory prompt is always added after all deferrals are exhausted. This means if you set cPVAL Reboot Prompt Count to 4, the user will receive:

  • 4 regular prompts (Yes/No buttons) — user can defer
  • 1 final prompt (OK button only) — reboot is mandatory
  • Total: 5 prompts before forced reboot

Example: cPVAL Reboot Prompt Count = 4

Prompt #cPVAL Times PromptedRemaining Count ShownMessage TypeButton(s)User ActionNext Step
104RegularYes / No"No" (defer)Updates field to Times Prompted = 1
213RegularYes / No"No" (defer)Updates field to Times Prompted = 2
322RegularYes / No"No" (defer)Updates field to Times Prompted = 3
431RegularYes / No"No" (defer)Updates field to Times Prompted = 4
540Final WarningOK only"OK" (mandatory)Initiates reboot after delay

Sample Message Progression

Prompt 1 (4 remaining):

An update has been installed on your computer. Would you like to restart now to
complete the installation of updates? You have 4 prompt(s) remaining before a forced
reboot. Next prompt will be sent in 4 hour(s).

Buttons: [Yes] [No]


Prompt 2 (3 remaining):

An update has been installed on your computer. Would you like to restart now to
complete the installation of updates? You have 3 prompt(s) remaining before a forced
reboot. Next prompt will be sent in 4 hour(s).

Buttons: [Yes] [No]


Prompt 3 (2 remaining):

An update has been installed on your computer. Would you like to restart now to
complete the installation of updates? You have 2 prompt(s) remaining before a forced
reboot. Next prompt will be sent in 4 hour(s).

Buttons: [Yes] [No]


Prompt 4 (1 remaining):

An update has been installed on your computer. Would you like to restart now to
complete the installation of updates? You have 1 prompt(s) remaining before a forced
reboot. Next prompt will be sent in 4 hour(s).

Buttons: [Yes] [No]


Prompt 5 — Final Warning (0 remaining):

An update has been installed on your computer. This is the final prompt before your
computer will automatically restart to complete the installation of updates. Please
save your work. Your computer will be restarted after 5 minute(s) after you
acknowledge this prompt.

Buttons: [OK] (Reboot is mandatory after acknowledgment)


Why This Design?

This approach gives users four opportunities to schedule their reboot at a time convenient to them, followed by one final warning before the system enforces the reboot automatically. The count always includes the final prompt in its total, ensuring users understand they have a finite number of deferrals before the reboot becomes mandatory.

Sample Prompts

With Default Values:
Image1

With Custom Header and Icon Image:
Image2

Changelog

2026-06-10

  • Missed prompt counter now uses real elapsed time instead of counting each script run. This makes the forced reboot timeline predictable no matter how often the detection script checks in.
  • Added safety checks for active installations before rebooting unattended machines. The script now looks for Windows Updates, feature upgrades, MSI installers, BITS downloads, and winget activity.
  • If a forced reboot is due but an install is still running, the reboot waits until the install finishes. It will trigger automatically on the next check after the install completes.
  • Machines with no user logged in will no longer reboot mid-update. The script exits safely and retries on the next cycle once servicing is done.
  • Winget (Windows Package Manager) is only treated as active when it is actually doing work, preventing false detections from an idle process.
  • Script documentation updated to reflect all of the above changes.

2026-06-03

  • Added support for missed-prompt tracking custom fields and forced reboot threshold handling.
  • Added default values for suppress window behavior, missed-prompt force reboot behavior, and no-user reboot behavior.

2026-05-26

  • Updated the solution to install .Net 10 Desktop Runtime instead of .Net 8.
  • Added a default values region in the PowerShell script.

2026-03-23

  • Updated .Net8 Desktop Runtime installation logic to install the latest available version.
  • Code Signed the PowerShell script.

2025-12-19

  • Initial version of the document