Subhrajyoti Singha 6d903a42e1 [CmdPal] Add "Update and restart" / "Update and shut down" system com… (#49437)
## Summary of the Pull Request

Adds **Update and restart** and **Update and shut down** to the Windows
System Commands extension, matching what Windows shows in the Start menu
power flyout when updates are waiting for a reboot.

Both only show up while Windows Update is actually waiting on a restart.
When nothing is pending, the command list is exactly what it is today.

## PR Checklist

- [x] Closes: #48849
- [x] **Communication:** commented on the issue before starting;
zadjii-msft had greenlit the idea as long as the commands actually do
something rather than just report status
- [x] **Tests:** added and passing (27/27)
- [ ] **Localization:** 6 new resx strings, each with a translator
comment
- [ ] **Dev docs:** n/a
- [ ] **New binaries:** n/a

## Detailed Description of the Pull Request / Additional comments

**Detecting the pending update.**
`WindowsUpdateHelper.IsUpdatePending()` reads
`ISystemInformation::RebootRequired` from WUAPI, which is the same
signal the Start menu uses, so the commands appear exactly when Windows
would offer them itself.

A few notes on that file, since the interop is a bit unusual:

- I used `[GeneratedComInterface]` rather than `ComImport` to keep it
AOT-compatible.
- `ISystemInformation` is a dual interface, so its first four vtable
slots belong to `IDispatch`. They're declared as placeholder methods
that are never called, and the two real members follow in vtable order.
- The result is cached for 5 seconds. `GetItems()` runs on every
keystroke and would otherwise create a COM object each time — same
reasoning as the existing network info cache in this extension.
- If anything goes wrong (COM creation fails, an exception is thrown) it
falls back to "no update pending", so the commands stay hidden and the
extension behaves exactly as it does now. The failure is logged through
`ExtensionHost.LogMessage`.

**Running the command.** `InitiateShutdown` with
`SHUTDOWN_INSTALL_UPDATES` plus either `SHUTDOWN_RESTART` (0x44) or
`SHUTDOWN_POWEROFF` (0x48). That first flag is what makes this "update
and restart" instead of a plain restart. `SeShutdownPrivilege` is
disabled by default on the process token, so it gets enabled first.

**Wiring.** Both items use the existing `ExecuteCommandConfirmation`
flow, so they respect the "confirm system commands" setting like the
other commands here. They're registered on the System Commands page and
the top-level search fallback, with stable ids
(`...system.update_restart`, `...system.update_shutdown`).

## One question for reviewers

`ShowDialogToConfirmCommand` defaults to `false`, so out of the box
these run immediately when you press Enter, the same as the existing
Shutdown and Restart commands. I kept them consistent rather than
special-casing them, but I hit this myself while testing — I pressed
Enter and my machine started updating and rebooting straight away, which
was a bit of a surprise. Happy to force a confirmation for these two
regardless of the setting if you'd prefer that.

## Validation Steps Performed

27/27 unit tests pass. The 5 new test methods cover the commands being
present/absent in both states, query matching, stable ids, the 0x44 /
0x48 flag values, and that the real WUAPI call doesn't throw.

I also tested it on a machine with a genuine pending update, confirmed
via WUAPI `RebootRequired` and the Windows Update and CBS registry keys:

1. **Before** — the installed 0.11 build, same machine, same pending
update: no update commands.
2. **After** — this build: both commands show up, in the same situation
the Start menu offers them.
3. **Search** — typing `update` matches both, which is the
discoverability gap the issue is about.
4. **Actually ran it** — pressing Enter on "Update and restart"
installed the pending update (KB5121767) and restarted the machine.
After it came back up, `RebootRequired` was false and the two commands
were correctly gone from the list.

### Screenshots

**1. Before**
<img width="785" height="473" alt="Screenshot 2026-07-21 214038"
src="https://github.com/user-attachments/assets/27b12a4c-f636-4815-b8e2-fc918282959b"
/>

**After**
<img width="762" height="445" alt="Screenshot 2026-07-21 215452"
src="https://github.com/user-attachments/assets/80e1936d-af67-48ab-91b4-59b94fb56827"
/>
<img width="762" height="149" alt="pr48849-search-update"
src="https://github.com/user-attachments/assets/53b7f065-4b7c-4317-9e66-e621eed44e61"
/>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-17 22:15:25 +00:00
2026-02-11 22:59:53 +01:00
2020-05-02 15:59:18 -07:00
2026-02-14 15:47:56 +08:00

Microsoft PowerToys

Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks.

Installation · Documentation · Blog · Release notes

🔨 Utilities

PowerToys includes over 30 utilities to help you customize and optimize your Windows experience:

Advanced Paste icon Advanced Paste Always on Top icon Always on Top Awake icon Awake
Color Picker icon Color Picker Command Not Found icon Command Not Found Command Palette icon Command Palette
Crop and Lock icon Crop And Lock Environment Variables icon Environment Variables FancyZones icon FancyZones
File Explorer Add-ons icon File Explorer Add-ons File Locksmith icon File Locksmith Grab And Move icon Grab And Move
Hosts File Editor icon Hosts File Editor Image Resizer icon Image Resizer Keyboard Manager icon Keyboard Manager
Light Switch icon Light Switch Mouse Utilities icon Mouse Utilities Mouse Without Borders icon Mouse Without Borders
New+ icon New+ Peek icon Peek PowerDisplay icon PowerDisplay
PowerRename icon PowerRename PowerToys Run icon PowerToys Run Quick Accent icon Quick Accent
Registry Preview icon Registry Preview Screen Ruler icon Screen Ruler Shortcut Guide icon Shortcut Guide
Text Extractor icon Text Extractor Workspaces icon Workspaces ZoomIt icon ZoomIt

📦 Installation

For detailed installation instructions and system requirements, visit the installation docs.

But to get started quickly, choose one of the installation methods below:

Download the .exe file from GitHub

Go to the PowerToys GitHub releases, scroll down and select Assets to reveal the installation files, and choose the one that matches your architecture and install scope. For most devices, that would be x64 per-user.

Microsoft Store
You can easily install PowerToys from the Microsoft Store:

WinGet
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli#installing-the-client). Updating PowerToys via winget will respect the current PowerToys installation scope. To install PowerToys, run the following command from the command line / PowerShell:
  • User scope installer (default)
winget install Microsoft.PowerToys -s winget
  • Machine-wide scope installer
winget install --scope machine Microsoft.PowerToys -s winget
Other methods
There are [community driven install methods](https://learn.microsoft.com/windows/powertoys/install#community-driven-install-tools) such as Chocolatey and Scoop. If these are your preferred install solutions, you can find the install instructions there.

What's new?

What's new image

To see what's new, check out the release notes.

🛣️ Roadmap

We are planning some nice new features and improvements for the next releases a brand-new Shortcut Guide experience, ensuring it's easier to find and install Command Palette extensions and so much more! Stay tuned for v0.100!

❤️ PowerToys Community

The PowerToys team is extremely grateful to have the support of an amazing active community. The work you do is incredibly important. PowerToys wouldn't be nearly what it is today without your help filing bugs, updating documentation, guiding the design, or writing features. We want to say thank you and take time to recognize your work. Your contributions and feedback improve PowerToys month after month!

Contributing

This project welcomes contributions of all types. Besides coding features / bug fixes, other ways to assist include spec writing, design, documentation, and finding bugs. We are excited to work with the power user community to build a set of tools for helping you get the most out of Windows. We ask that before you start work on a feature that you would like to contribute, please read our Contributor's Guide. We would be happy to work with you to figure out the best approach, provide guidance and mentorship throughout feature development, and help avoid any wasted or duplicate effort. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you grant us the rights to use your contribution and that you have permission to do so. For guidance on developing for PowerToys, please read the developer docs for a detailed breakdown. This includes how to setup your computer to compile.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct.

Privacy statement

The application logs basic diagnostic data (telemetry). For more privacy information and what we collect, see our PowerToys Data and Privacy documentation.

Description
Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks
Readme MIT 734 MiB
Languages
C 45.1%
C# 26.1%
JavaScript 14.1%
C++ 13.8%
PowerShell 0.6%
Other 0.2%