Skip to main content

Reboot Pending Prompt - Autofix [Macintosh]

Overview

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

Unlike Windows, where RMM scripts run in an isolated Session 0 and require Scheduled Task wrappers to display a GUI, macOS scripts running as root from NinjaRMM can render directly in the console user's active session. Therefore, this script executes the OmniPrompt.app utility directly, simplifying the execution flow while maintaining the same robust "Deferral" vs. "Forced" phase logic.

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 macOS software update, application installer, or feature upgrade.

The following macOS-specific processes are checked:

SignalWhat It Means
softwareupdatemacOS Software Update is actively installing an update
installA general macOS installer package is running
msudmacOS Software Update Daemon is active
setupdmacOS Setup Assistant or installer is running
osinstallersetupdmacOS OS Installer is actively performing an upgrade

Note: This check only blocks unattended reboots. If a user is at their desk and clicks "Yes" or "OK" 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 action of the Reboot Pending Prompt - Macintosh compound condition.
  • OmniPrompt is a cross-platform, Go-based GUI utility that runs natively on macOS without requiring any external runtimes (like .NET).

Dependencies

Custom Fields

Custom FieldTypeExampleScopeAvailable OptionsEditableDescription
cPVAL Reboot Prompt CountNumeric5Organization, Location, DeviceN/AYesMax deferrals allowed before a forced reboot.
cPVAL Reboot Prompt Duration Between PromptNumeric4Organization, Location, DeviceN/AYesMinimum hours to wait between prompts.
cPVAL Reboot Prompt TitleTextIT Dept: Important UpdatesOrganization, Location, DeviceN/AYesTitle of the GUI window.
cPVAL Reboot Prompt MessageMulti-lineWe installed security patches.Organization, Location, Device, End UserN/AYesCustom message body. Supports message substitution variables.
cPVAL Final Prompt MessageMulti-lineDeferrals exhausted.Organization, Location, DeviceN/AYesMessage displayed when no deferrals remain. Supports message substitution variables.
cPVAL Reboot Prompt TimeoutNumeric600Organization, Location, DeviceN/AYesTime in seconds before a "Warning" prompt closes automatically.
cPVAL Final Prompt TimeoutNumeric900Organization, Location, DeviceN/AYesTime in seconds before a "Final" prompt closes automatically.
cPVAL Final Prompt Reboot Delay MinutesNumeric10Organization, Location, DeviceN/AYesGrace period (in minutes) after final acknowledgment before the forced reboot occurs.
cPVAL Reboot Prompt Header ImageTexthttps://example.com/logo.pngOrganization, Location, DeviceN/AYesLocal file path or URL for the header image.
cPVAL Reboot Prompt Icon ImageTextC:\Logos\icon.icoOrganization, Location, DeviceN/AYesLocal file path or URL for the icon image.
cPVAL Reboot Prompt ThemeDropdownDarkOrganization, Location, DeviceDark, LightYesUI Theme: "Dark" or "Light".
cPVAL Reboot if Not Logged InDropdownEnableOrganization, Location, DeviceDisable, EnableYesForces reboot immediately if no user session is active.
cPVAL Reboot During Suppress PeriodDropdownEnableOrganization, Location, DeviceDisable, EnableYesAllows unattended/forced reboots during suppress windows or weekends.
cPVAL Reboot Prompt Suppress Time WindowText1800-0800Organization, Location, DeviceN/AYes24-hour time range (HHmm-HHmm) to suppress prompts. Leave blank to disable.
cPVAL Max Missed Prompts Before ForceNumeric3Organization, Location, DeviceN/AYesNumber of consecutive missed prompts before forcing a reboot without showing the GUI. Set to 0 to disable.
cPVAL Reboot Prompt SizeText640x480Organization, Location, DeviceN/AYesSize of the prompt window (WIDTHxHEIGHT).
cPVAL Reboot Prompt Text Box SizeText500x200Organization, Location, DeviceN/AYesSize of the text box (WIDTHxHEIGHT).
cPVAL Reboot Prompt Logo SizeText400x150Organization, Location, DeviceN/AYesSize of the logo (WIDTHxHEIGHT).
cPVAL Reboot Prompt Text SizeNumeric14Organization, Location, DeviceN/AYesFont size for the message text.
cPVAL Reboot Prompt Text StyleTextArialOrganization, Location, DeviceN/AYesFont family for the message text.
cPVAL Reboot Prompt Button Text StyleTextArialOrganization, Location, DeviceN/AYesFont family for button text.
cPVAL Reboot Prompt Button Text SizeNumeric14Organization, Location, DeviceN/AYesFont size for button text.
cPVAL Reboot Prompt Button SizeText100x40Organization, Location, DeviceN/AYesSize of each button (WIDTHxHEIGHT).
cPVAL Reboot Prompt Title Text StyleTextArialOrganization, Location, DeviceN/AYesFont family for the title bar text.
cPVAL Reboot Prompt Title Text SizeNumeric14Organization, Location, DeviceN/AYesFont size for the title bar text.
cPVAL Reboot Prompt Title Field SizeText640x35Organization, Location, DeviceN/AYesSize of the title bar (WIDTHxHEIGHT).
cPVAL Last PromptedText2024-05-20 14:30:00DeviceN/ANoUpdated to current timestamp if user defers. Updated by script.
cPVAL Times PromptedNumeric2DeviceN/ANoIncremented by 1 if user defers. Resets to 0 on Reboot. Updated by script.
cPVAL Pending RebootCheckboxFalseDeviceTrue, FalseYesSet to False upon successful reboot initiation. Updated by script.
cPVAL Consecutive Missed PromptsNumeric2DeviceN/ANoTracks consecutive missed prompts. Managed by the Detection script and reset on reboot.
cPVAL First Missed Prompt TimeText2024-05-20 14:30:00DeviceN/ANoRecords when the current missed-prompt streak started. Managed by the Detection script and reset on reboot.

Configuration Hierarchy

The solution evaluates settings using a strict top-down hierarchy. If a value is configured at a higher priority level, it overrides the lower levels.

PriorityLevelDescription
1 (Highest)Device Level Custom FieldOverrides all lower levels. Applied to a specific endpoint.
2Location Level Custom FieldOverrides Organization level. Applied to all endpoints in a location.
3Organization Level Custom FieldGlobal default for the entire tenant.
4 (Lowest)Script Runtime VariableUltimate fallback default used if the custom field is blank at all levels.

Script Variables

Instead of hardcoding defaults, the script relies on NinjaRMM Script Variables as the ultimate fallback mechanism. You can configure these variables directly in the script's settings within NinjaRMM to establish global baseline behaviors without modifying the script file.

NameTypeExampleDefaultAvailable OptionsDescription
Prompt TitleString/TextAction RequiredUpdates Installed - Reboot RequiredN/ATitle of the GUI window.
Regular Prompt MessageString/TextSecurity updates applied.Built-in standard messageN/ADefault message for regular prompts. Supports message substitution variables.
Final Prompt MessageString/TextFinal warning.Built-in final warning messageN/ADefault message for final prompts. Supports message substitution variables.
Prompt CountInteger54N/AMax deferrals allowed before a forced reboot.
Final Reboot Delay MinutesInteger105N/AGrace period after final acknowledgment.
Duration Between PromptsInteger64N/AMinimum hours to wait between prompts.
Regular Prompt Timeout SecondsInteger600300N/ATime in seconds before a Warning prompt closes automatically.
Final Prompt Timeout SecondsInteger1200900N/ATime in seconds before a Final prompt closes automatically.
Prompt ThemeDropdownLightDarkDark, LightSets the UI theme.
Header ImageString/Texthttps://example.com/logo.png(blank)N/ALocal file path or URL for the header image.
Icon ImageString/Text/opt/logos/icon.icns(blank)N/ALocal file path or URL for the icon image.
Suppress Time WindowString/Text1800-0800(blank)N/A24h time range (HHmm-HHmm) to suppress prompts.
Max Missed Prompts Before ForceInteger30N/ANumber of consecutive missed prompts before forcing a reboot without GUI.
Reboot If Not Logged InDropdownEnableDisableDisable, EnableEnable to reboot immediately if no user is signed in.
Reboot During Suppress PeriodDropdownEnableDisableDisable, EnableFallback default. Allows unattended/forced reboots during suppress windows.

💡 Note: Do not attempt to change default values by editing the script file directly. Modifying the script may break its execution. Always use Custom Fields or Script Variables to adjust behaviors.

Message Substitution Variables

The following tokens can be used in ANY prompt message - the Regular Prompt Message, the Final Prompt Message, or their custom-field equivalents (cPVAL Reboot Prompt Message / cPVAL Final Prompt Message). Write them in PascalCase with NO surrounding symbols; each is replaced with its live value when the prompt is displayed.

TokenDescriptionExample
PromptsToSendTotal prompts the user will receive (regular + final)5
PromptsSentNumber of prompts shown so far, including the current one2
PromptsLeftRemaining prompts before the forced/final one3
PromptIntervalMinutesInterval between prompts, in minutes240
PromptIntervalHoursSame interval, in hours4
RegularTimeoutSecondsRegular prompt timeout, in seconds600
RegularTimeoutMinutesSame timeout, in minutes10
FinalTimeoutSecondsFinal prompt timeout, in seconds900
FinalTimeoutMinutesSame timeout, in minutes15
DelayAfterFinalSecondsDelay after the final prompt before reboot, in seconds900
DelayAfterFinalMinutesSame delay, in minutes15
ScheduledRebootTimeClock time (HH:MM) of the automatic reboot (now + final delay)14:30
MinutesUntilRebootMinutes until the automatic reboot (the final delay)10
ComputerNameMachine nameMAC-OFFICE-01
UserNameLogged-in (console) usernamejsmith

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: Displays the OmniPrompt GUI directly in the console user's session.

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

Sample Prompts

Example Configuration:

Custom FieldValue
cPVAL Pending RebootYes
cPVAL Reboot Prompt Count5
cPVAL Reboot Prompt TitleRestart Required: The Updates Are Getting Impatient
cPVAL Reboot Prompt MessageDear UserName, \n\nWe successfully installed some updates. Now, they are demanding a reboot to finish their work. Will you oblige them now, or shall we play this game a few more times?\n\nYou currently have PromptsLeft polite request(s) remaining before we are forced to reboot the machine for you.\n\nIf you choose to ignore this, we will politely bother you again in PromptIntervalHours hour(s).
cPVAL Reboot Prompt Timeout600
cPVAL Final Prompt MessageDear UserName, \n\nWell, this is it. The updates are installed, and we have officially run out of polite requests. This is the absolute final prompt before we take matters into our own hands and restart your computer.\n\nPlease save your work. Once you acknowledge this prompt, the inevitable reboot will occur in DelayAfterFinalMinutes minute(s).\n\nThank you for your cooperation!
cPVAL Final Prompt Timeout900
cPVAL Reboot Prompt ThemeDark
cPVAL Reboot Prompt Header Imagehttps://content.provaltech.com/img/logo_r4.png
cPVAL Reboot Prompt Icon Imagehttps://www.provaltech.com/favicon.ico

Prompt 1 (5 remaining):
Image1

Prompt 2 (4 remaining):
Image2

Prompt 3 (3 remaining):
Image3

Prompt 4 (2 remaining):
Image4

Prompt 5 (1 remaining):
Image5

Prompt 6 (Final - 0 remaining):
Image6

macOS Reboot Behavior: Unlike Windows, macOS does not display a shutdown message. When the user clicks "Yes" to reboot, the system will restart approximately one minute later. This delay allows the script sufficient time to update the custom fields before the reboot occurs.

Changelog

2026-07-20

  • Initial version of the document.