[GPO]Add policy to define the run at startup setting (#37385)

* [GPO]Add policy to define the run at startup setting

* Use message for single setting managed by policy instead
This commit is contained in:
Jaime Bernardo
2025-02-12 18:49:49 +00:00
committed by GitHub
parent 0c7a1dd316
commit 58d34087ee
10 changed files with 88 additions and 4 deletions

View File

@@ -263,9 +263,21 @@
</ComboBox>
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard x:Uid="GeneralPage_RunAtStartUp">
<tkcontrols:SettingsCard x:Uid="GeneralPage_RunAtStartUp" IsEnabled="{x:Bind ViewModel.IsRunAtStartupGPOManaged, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.Startup, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<InfoBar
x:Uid="GPO_SettingIsManaged"
BorderThickness="0"
CornerRadius="0"
IsClosable="False"
IsOpen="{x:Bind ViewModel.IsRunAtStartupGPOManaged, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.IsRunAtStartupGPOManaged, Mode=OneWay}"
Severity="Informational">
<InfoBar.IconSource>
<FontIconSource FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72E;" />
</InfoBar.IconSource>
</InfoBar>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="General_SettingsBackupAndRestoreTitle" Visibility="Visible">

View File

@@ -121,7 +121,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_isDevBuild = Helper.GetProductVersion() == "v0.0.1";
_startup = GeneralSettingsConfig.Startup;
_runAtStartupGpoRuleConfiguration = GPOWrapper.GetConfiguredRunAtStartupValue();
if (_runAtStartupGpoRuleConfiguration == GpoRuleConfigured.Disabled || _runAtStartupGpoRuleConfiguration == GpoRuleConfigured.Enabled)
{
// Get the enabled state from GPO.
_runAtStartupIsGPOConfigured = true;
_startup = _runAtStartupGpoRuleConfiguration == GpoRuleConfigured.Enabled;
}
else
{
_startup = GeneralSettingsConfig.Startup;
}
_showNewUpdatesToastNotification = GeneralSettingsConfig.ShowNewUpdatesToastNotification;
_autoDownloadUpdates = GeneralSettingsConfig.AutoDownloadUpdates;
_showWhatsNewAfterUpdates = GeneralSettingsConfig.ShowWhatsNewAfterUpdates;
@@ -204,6 +215,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private static bool _isDevBuild;
private bool _startup;
private GpoRuleConfigured _runAtStartupGpoRuleConfiguration;
private bool _runAtStartupIsGPOConfigured;
private bool _isElevated;
private bool _runElevated;
private bool _isAdmin;
@@ -251,6 +264,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
set
{
if (_runAtStartupIsGPOConfigured)
{
// If it's GPO configured, shouldn't be able to change this state.
return;
}
if (_startup != value)
{
_startup = value;
@@ -524,6 +543,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
get => _enableDataDiagnosticsIsGpoDisallowed;
}
public bool IsRunAtStartupGPOManaged
{
get => _runAtStartupIsGPOConfigured;
}
public string SettingsBackupAndRestoreDir
{
get