Skip to content

[GPO] Add policy to disable Awake's indefinitely mode#48025

Open
raihua wants to merge 25 commits into
microsoft:mainfrom
raihua:dev/raihua/gpo-add-policy-for-disable-awake-indefinitely
Open

[GPO] Add policy to disable Awake's indefinitely mode#48025
raihua wants to merge 25 commits into
microsoft:mainfrom
raihua:dev/raihua/gpo-add-policy-for-disable-awake-indefinitely

Conversation

@raihua
Copy link
Copy Markdown

@raihua raihua commented May 21, 2026

Summary of the Pull Request

This introduces a group policy to disable Awake's "Indefinitely" mode.

This PR follows the implementation of how Enabled state is managed by group policy.
The Indefinite state is saved in settings.json of module settings.
On file read, it reads the group policies value again to prevent users from enabling via settings.json.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Updated PowerToys.adml.

  • Revision number increased.
  • Added supported version definition .
  • Defined a policy with registry location.

Updated ADMX file:

  • Increased revision number.
  • Add strings for version, title, description.

Updated code:

  • Added to GPO.h.
  • Added to GPO wrapper for C# access.
  • Updated module interface.
  • Modified settings UI to show lock when policy applied.

Could not:

  • Add checks in executable to prevent direct launching.
  • Update dashboard helper to respect policy.

Updated Bug report tool:

  • Added to bug report tool to capture policy state.

Validation Steps Performed

  1. Set ConfigureEnabledAwakeIndefinitely to 0 at Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys.
  2. Set ConfigureEnabledUtilityAwake to 1 as well.
  3. Started PowerToys Settings and Awake.
  4. Confirmed Awake Settings page showed Indefinite mode greyed out and a warning for GP enforced.
  5. Confirmed Indefinite mode greyed out in Awake system tray.
  6. Set ConfigureEnabledAwakeIndefinitely to 1 in registry.
  7. On refresh or restart of PowerToys, greyed out options are now selectable.
  8. Checked settings.json for IndefiniteEnabledValue and found to match registry value ConfigureEnabledAwakeIndefinitely.
  9. Ran bug report tool and confirmed the ConfigureEnabledAwakeIndefinitely is working.

Screenshots

image image image

raihua added 25 commits May 6, 2026 08:35
Add related variables and methods to get and set IndefiniteEnabledValue based on GPO
This updates the view model's gpo indefinite enabled property and marks it as GPO managed.
This disables the mode based on the GPO
@raihua
Copy link
Copy Markdown
Author

raihua commented May 21, 2026

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Collaborator

@daverayment daverayment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thanks for your contribution. There are a few issues with this which need attention:

PR template

  • Your linked issue is incorrect
  • You've noted that you've communicated with maintainers, but not provided a link to the approval to work on this
  • You've noted that you've updated tests, but there aren't any new ones here, or changes to existing ones

The PR itself

  • Your PowerToys.adml and PowerToys.admx files are in the wrong place. They need to be under src/gpo/assets/en-US and src/gpo/assets respectively
  • The new configuration setting ConfigureEnabledAwakeIndefinitely in the .adml is not named according to the convention, which is ConfigureEnabledUtility<UtilityName><UtilityFeature>. It should likely be ConfigureEnabledUtilityAwakeIndefiniteMode
  • The naming throughout is not ideal. AwakeIndefinitely should likely be a noun phrase like AwakeIndefiniteMode or AwakeIndefiniteModeEnabled where relevant
  • The policy in the .admx file has a supportedOn property of SUPPORTED_POWERTOYS_0_99_2. This is incorrect, as this new feature won't be supported until PowerToys 0.101 at the earliest. We'll need another definition to cover this, e.g. SUPPORTED_POWERTOYS_0_101_0
  • Please don't update the version number of the .admx or .adml files. This doesn't refer to the revision of the files, but the version of the ADMX/ADML format itself
  • Have you tested with GPEdit.msc? This is the tool used to edit the settings themselves. The registry should not be edited directly. Please provide some screenshots to show this, as it illustrates that the .admx and .adml files are in the correct format and that your text is being displayed correctly
  • The tray menu entry is disabled with no indication to the user why it's unavailable. This isn't great UX. We should likely append " (disabled by admin)" or similar
  • The setting seems to only apply to interactions with the tray menu. What happens if the user runs Awake via the CLI? Your write-up suggests that this is a known issue. If that's the case, then the PR should be a draft, as it's still a work in progress. If a user can simply run Awake via the command line to get around the restriction, it's not working properly
  • It's wrong to persist GPO properties to the settings.json file. GPO is a read-only resource and the settings.json is at a different layer, i.e. user-editable and untrusted. IndefiniteEnabledValue should not be added to AwakeProperties or persisted to settings.json. GPO values should be read directly from the registry at runtime via the appropriate GetConfigured...Value method
  • It would be useful to have the setting output in the console when Awake in run via the CLI, e.g. "The option to keep awake indefinitely has been disabled by your administrator". You will also need to think about error messages and the appropriate flow for when the user doesn't set an expiry time or interval and indefinite mode is disabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerToys update problem

2 participants