How to generate a Popup Window for User Confirmation with "Proceed" or "Abort" when user commands Shutdown or Restart?

Amit Bhowmick 0 Reputation points
2025-02-11T07:04:22.6333333+00:00

My team mostly works on shared files in our Workstations (Windows 11 Pro) connected in LAN. In the past we had problem of losing few Team members work due to Restart/Shutdown of Host Computer. In few cases it happened due to Auto Restart after Windows Update and in few cases due to Manual Restart/Shutdown by the User working in Host Computer.

Is there any way to Generate a Popup Window automatically when an user commands Shutdown or Restart the Workstation he/she is working which could be a Host Computer for some shared files?

If yes, the Popup Window must hold the Shutdown/Restart Process till the User confirms to "Proceed" or "Abort" it.

Can this popup hold the Auto Restart Process after Windows Updates?

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,786 questions
Microsoft System Center
Microsoft System Center
A suite of Microsoft systems management products that offer solutions for managing datacenter resources, private clouds, and client devices.
1,072 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,698 questions
Microsoft Configuration Manager Updates
Microsoft Configuration Manager Updates
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Updates: Broadly released fixes addressing specific issue(s) or related bug(s). Updates may also include new or modified features (i.e. changing default behavior).
1,100 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. XinGuo-MSFT 20,971 Reputation points
    2025-02-11T08:11:12.2566667+00:00

    Hi,

    To generate a popup window for user confirmation when a shutdown or restart is initiated on a Windows 11 Pro workstation, you can use a combination of Group Policy settings and custom scripts. Here's how you can achieve this:

    Step 1: Enable Shutdown Event Tracker

    1. Press Win + R, type gpedit.msc, and press Enter to open the Group Policy Editor.
    2. Navigate to Computer Configuration > Administrative Templates > System.
    3. Double-click on Display Shutdown Event Tracker.
    4. Set it to Enabled and choose Always.
    5. Click Apply and OK.

    This will prompt users to provide a reason for shutdown or restart, but it won't hold the process until confirmation.

    Step 2: Create a Custom Script for Confirmation

    You can create a custom script that prompts the user for confirmation before proceeding with the shutdown or restart. Here's an example using PowerShell:

    Create the PowerShell Script:

    $result = [System.Windows.Forms.MessageBox]::Show('Do you want to proceed with Shutdown/Restart?', 'Confirmation', 'YesNo', 'Warning')
    if ($result -eq 'Yes') {
        Stop-Computer -Force
    } else {
        Write-Host 'Shutdown/Restart Aborted'
    }
    

    Save the Script: Save the script as ConfirmShutdown.ps1.

    Create a Scheduled Task:

    • Open Task Scheduler and create a new task.
      • Set the trigger to run the script when a shutdown or restart is initiated.
      • In the Actions tab, set the action to start a program and point it to powershell.exe with the argument -File "C:\Path\To\ConfirmShutdown.ps1".

    Step 3: Prevent Auto Restart After Windows Updates

    To prevent automatic restarts after Windows updates, you can use Group Policy or Registry Editor:

    Using Group Policy:

    • Open Group Policy Editor (gpedit.msc).
    • Navigate to Computer Configuration > Administrative Templates > Windows Components > Windows Update.
    • Double-click on No auto-restart with logged on users for scheduled automatic updates installations.
    • Set it to Enabled and click Apply and OK.

    Using Registry Editor:

    • Open Registry Editor (regedit).
    • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU.
    • Create a new DWORD (32-bit) Value named NoAutoRebootWithLoggedOnUsers and set its value to 1.

    These steps should help you create a confirmation popup and prevent automatic restarts after updates.

    If you need further assistance or run into any issues, feel free to ask! How's your team managing with the shared files so far?

    0 comments No comments

  2. Bailey Morris 0 Reputation points
    2025-02-11T08:15:36.6733333+00:00

    If you want to completely block shutdown/restart without confirmation, you can use shutdown.exe with the /a option, which cancels shutdown, and bind it to a service that monitors shutdown attempts.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.