mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
[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:
@@ -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="" />
|
||||
</InfoBar.IconSource>
|
||||
</InfoBar>
|
||||
</controls:SettingsGroup>
|
||||
|
||||
<controls:SettingsGroup x:Uid="General_SettingsBackupAndRestoreTitle" Visibility="Visible">
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user