mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-02-18 16:36:29 +00:00
Compare commits
6 Commits
2026.02.04
...
2026.02.07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8c2c6ddd7 | ||
|
|
1ea2c63522 | ||
|
|
675882cb3b | ||
|
|
ae4d19f59c | ||
|
|
327f4ee7ab | ||
|
|
3af62159a5 |
@@ -351,7 +351,7 @@
|
||||
"UndoAction": "Show",
|
||||
"RegistryUndoKey": "Enable_Start_Recommended.reg",
|
||||
"MinVersion": 22621,
|
||||
"MaxVersion": 26199
|
||||
"MaxVersion": null
|
||||
},
|
||||
{
|
||||
"FeatureId": "DisableBing",
|
||||
|
||||
@@ -159,6 +159,13 @@
|
||||
<Trigger Property="SelectedIndex" Value="-1">
|
||||
<Setter TargetName="ClosedAccentLine" Property="Visibility" Value="Collapsed"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="ClosedAccentLine" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonDisabled}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>
|
||||
<Setter Property="Opacity" Value="0.6"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
@@ -238,21 +245,66 @@
|
||||
<!-- Category header text style -->
|
||||
<Style x:Key="CategoryHeaderTextBlock" TargetType="TextBlock">
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="FontSize" Value="15"/>
|
||||
<Setter Property="FontSize" Value="16"/>
|
||||
<Setter Property="Margin" Value="0,0,0,10"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource FgColor}"/>
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<!-- Category help link button/text styles -->
|
||||
<Style x:Key="CategoryHelpLinkButtonStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Margin" Value="6,1,0,10"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonBg}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="Transparent" BorderBrush="Transparent" BorderThickness="0">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonHover}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonPressed}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="CategoryHelpLinkTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Foreground">
|
||||
<Setter.Value>
|
||||
<Binding RelativeSource="{RelativeSource AncestorType=Button}" Path="Foreground"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Overview changes text style -->
|
||||
<Style x:Key="OverviewNoChangesTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource FgColor}"/>
|
||||
<Setter Property="Margin" Value="0,0,0,8"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="FontStyle" Value="Italic"/>
|
||||
<Setter Property="Margin" Value="0,8,0,0"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="OverviewChangeBulletStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource FgColor}"/>
|
||||
<Setter Property="Margin" Value="0,8,0,0"/>
|
||||
<Setter Property="Margin" Value="0,0,0,8"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
</Style>
|
||||
|
||||
@@ -261,6 +313,41 @@
|
||||
<Setter Property="CaretBrush" Value="{DynamicResource FgColor}"/>
|
||||
</Style>
|
||||
|
||||
<!-- User TextBox Style with disabled state -->
|
||||
<Style x:Key="UserTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="CaretBrush" Value="{DynamicResource FgColor}"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource FgColor}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="Margin" Value="1,0,0,1"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonDisabled}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>
|
||||
<Setter Property="Opacity" Value="0.6"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- User TextBox Border Style with disabled state -->
|
||||
<Style x:Key="UserTextBoxBorderStyle" TargetType="Border">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderColor}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="CornerRadius" Value="4"/>
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBgColor}"/>
|
||||
<Setter Property="Padding" Value="8,6"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonDisabled}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="Opacity" Value="0.6"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- CheckBox Style -->
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Foreground" Value="{DynamicResource FgColor}"/>
|
||||
@@ -291,6 +378,13 @@
|
||||
<Setter TargetName="CheckBoxBorder" Property="BorderBrush" Value="{DynamicResource ButtonBg}"/>
|
||||
<Setter TargetName="CheckMark" Property="Foreground" Value="White"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="CheckBoxBorder" Property="Background" Value="{DynamicResource ButtonDisabled}"/>
|
||||
<Setter TargetName="CheckBoxBorder" Property="BorderBrush" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>
|
||||
<Setter Property="Opacity" Value="0.6"/>
|
||||
<Setter TargetName="CheckMark" Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="True"/>
|
||||
@@ -560,10 +654,9 @@
|
||||
</TextBlock>
|
||||
|
||||
<!-- Start Button -->
|
||||
<Button x:Name="HomeStartBtn" Width="200" Height="48" Style="{StaticResource Win11Button}" HorizontalAlignment="Center" Margin="0,50,0,0" AutomationProperties.Name="Start">
|
||||
<Button x:Name="HomeStartBtn" Width="125" Height="53" Style="{StaticResource Win11Button}" HorizontalAlignment="Center" Margin="0,20,0,0" AutomationProperties.Name="Start">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Text="Start" VerticalAlignment="Center" FontSize="20" Margin="0,0,0,2"/>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="16" Margin="8,0,0,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="Start" FontWeight="SemiBold" VerticalAlignment="Center" FontSize="24" Margin="0,0,0,3"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
@@ -744,18 +837,27 @@
|
||||
<Grid>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="0,-20,0,0" Padding="20,10,20,0">
|
||||
<StackPanel Margin="0,10,0,5">
|
||||
<!-- Selected Changes -->
|
||||
<Border BorderBrush="{DynamicResource BorderColor}" BorderThickness="1" CornerRadius="4" Background="{DynamicResource CardBgColor}" Padding="16,12,16,4" Margin="0,0,0,16">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Selected Changes" Style="{StaticResource CategoryHeaderTextBlock}"/>
|
||||
<StackPanel x:Name="OverviewChangesPanel"/>
|
||||
<StackPanel Margin="0,0,0,3"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Apply Changes To -->
|
||||
<Border BorderBrush="{DynamicResource BorderColor}" BorderThickness="1" CornerRadius="4" Background="{DynamicResource CardBgColor}" Padding="16,12" Margin="0,0,0,16">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Apply Changes To" FontWeight="Bold" FontSize="14" Foreground="{DynamicResource FgColor}" Margin="0,0,0,8"/>
|
||||
<ComboBox x:Name="UserSelectionCombo" Margin="0,0,0,12" AutomationProperties.Name="Apply Changes To">
|
||||
<TextBlock Text="Apply Changes To" Style="{StaticResource CategoryHeaderTextBlock}"/>
|
||||
<ComboBox x:Name="UserSelectionCombo" Margin="0,0,0,6" AutomationProperties.Name="Apply Changes To">
|
||||
<ComboBoxItem Content="Current User" IsSelected="True"/>
|
||||
<ComboBoxItem Content="Other User"/>
|
||||
<ComboBoxItem Content="Windows Default User (Sysprep)"/>
|
||||
</ComboBox>
|
||||
<StackPanel x:Name="OtherUserPanel" Visibility="Collapsed" Margin="0,0,0,12">
|
||||
<StackPanel x:Name="OtherUserPanel" Visibility="Collapsed" Margin="0,0,0,6">
|
||||
<TextBlock x:Name="UsernameValidationMessage" Text="" FontStyle="Italic" Foreground="{DynamicResource CloseHover}" FontSize="11" Margin="3,0,0,4" TextWrapping="Wrap"/>
|
||||
<Border BorderBrush="{DynamicResource ButtonBorderColor}" BorderThickness="1" CornerRadius="4" Background="{DynamicResource ComboBgColor}" Padding="8,6">
|
||||
<Border Style="{StaticResource UserTextBoxBorderStyle}" IsEnabled="{Binding ElementName=OtherUsernameTextBox, Path=IsEnabled}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
@@ -763,36 +865,36 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="" FontFamily="Segoe MDL2 Assets" FontSize="14" VerticalAlignment="Center" Margin="4,0,8,0" Foreground="{DynamicResource FgColor}"/>
|
||||
<TextBlock x:Name="UsernameTextBoxPlaceholder" Grid.Column="1" Text="Enter username" Foreground="{DynamicResource FgColor}" Opacity="0.5" FontSize="13" Margin="3,0,0,1" VerticalAlignment="Center" IsHitTestVisible="False"/>
|
||||
<TextBox x:Name="OtherUsernameTextBox" Grid.Column="1" Background="Transparent" Foreground="{DynamicResource FgColor}" BorderThickness="0" FontSize="13" Margin="1,0,0,1" VerticalAlignment="Center" Text="" Padding="0" AutomationProperties.Name="Enter username"/>
|
||||
<TextBox x:Name="OtherUsernameTextBox" Grid.Column="1" Style="{StaticResource UserTextBoxStyle}" Text="" AutomationProperties.Name="Enter username"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
<TextBlock x:Name="UserSelectionDescription" Text="Changes will be applied to the currently logged-in user profile." Foreground="{DynamicResource FgColor}" FontSize="12" TextWrapping="Wrap"/>
|
||||
<TextBlock x:Name="UserSelectionDescription" Text="Changes will be applied to the currently logged-in user profile." Foreground="{DynamicResource FgColor}" FontSize="12" TextWrapping="Wrap" Margin="0,6,0,3"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Selected Changes -->
|
||||
<Border BorderBrush="{DynamicResource BorderColor}" BorderThickness="1" CornerRadius="4" Background="{DynamicResource CardBgColor}" Padding="16,12" Margin="0,0,0,16">
|
||||
<!-- Options -->
|
||||
<Border BorderBrush="{DynamicResource BorderColor}" BorderThickness="1" CornerRadius="4" Background="{DynamicResource CardBgColor}" Padding="16,12,16,3" Margin="0,0,0,16">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Selected Changes" FontWeight="Bold" FontSize="14" Foreground="{DynamicResource FgColor}"/>
|
||||
<StackPanel x:Name="OverviewChangesPanel"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- System Restore Point -->
|
||||
<Border BorderBrush="{DynamicResource BorderColor}" BorderThickness="1" CornerRadius="4" Background="{DynamicResource CardBgColor}" Padding="16,12" Margin="0,0,0,16">
|
||||
<StackPanel>
|
||||
<TextBlock Text="System Restore Point" FontWeight="Bold" FontSize="14" Foreground="{DynamicResource FgColor}" Margin="0,0,0,8"/>
|
||||
<TextBlock Text="A restore point will allow you to revert your system to a previous state using the built-in System Restore feature. (Recommended)" Foreground="{DynamicResource FgColor}" FontSize="12" Margin="0,0,0,10" TextWrapping="Wrap"/>
|
||||
<CheckBox x:Name="RestorePointCheckBox" Content="Create system restore point" Foreground="{DynamicResource FgColor}" AutomationProperties.Name="Create system restore point"/>
|
||||
<TextBlock Text="Options" Style="{StaticResource CategoryHeaderTextBlock}"/>
|
||||
|
||||
<!-- Restore Point Option -->
|
||||
<StackPanel>
|
||||
<CheckBox x:Name="RestorePointCheckBox" Style="{StaticResource FeatureCheckboxStyle}" Content="Create a system restore point (Recommended)" AutomationProperties.Name="Create a system restore point (Recommended)"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Restart Explorer Option -->
|
||||
<StackPanel>
|
||||
<CheckBox x:Name="RestartExplorerCheckBox" Style="{StaticResource FeatureCheckboxStyle}" Content="Restart the Windows Explorer process to apply all changes immediately" AutomationProperties.Name="Restart the Windows Explorer process to apply all changes immediately"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Apply Changes Button -->
|
||||
<Button x:Name="OverviewApplyBtn" Style="{StaticResource Win11Button}" Padding="14,8" Margin="0,0,0,15" HorizontalAlignment="Center" AutomationProperties.Name="Apply Changes">
|
||||
<Button x:Name="OverviewApplyBtn" Style="{StaticResource Win11Button}" Width="190" Height="44" Margin="0,0,0,15" HorizontalAlignment="Center" AutomationProperties.Name="Apply Changes">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Text="Apply Changes" VerticalAlignment="Center" FontSize="16" Margin="0,0,0,2"/>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="16" Margin="8,0,0,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="20" FontWeight="SemiBold" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="Apply Changes" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold" Margin="8,0,0,4"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
@@ -830,10 +932,12 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header -->
|
||||
<StackPanel Grid.Row="0" Margin="20,10,20,10">
|
||||
<TextBlock Text="Applying Changes" FontWeight="Bold" FontSize="20" Margin="0,0,0,10" Foreground="{DynamicResource FgColor}"/>
|
||||
<TextBlock Text="Sit back and relax while Win11Debloat applies your selected changes" FontSize="13" Margin="0,0,0,10" Foreground="{DynamicResource FgColor}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
<Border DockPanel.Dock="Top" Padding="20,10,20,0">
|
||||
<StackPanel Grid.Row="0">
|
||||
<TextBlock Text="Applying Changes" FontWeight="Bold" FontSize="20" Margin="0,0,0,5" Foreground="{DynamicResource FgColor}"/>
|
||||
<TextBlock Text="Sit back and relax while Win11Debloat applies your selected changes" FontSize="13" Margin="0,0,0,20" Foreground="{DynamicResource FgColor}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Console Output -->
|
||||
<Border Grid.Row="1" BorderBrush="{DynamicResource BorderColor}" BorderThickness="1" CornerRadius="4" Background="#0C0C0C" Margin="20,0">
|
||||
|
||||
@@ -17,4 +17,4 @@ Windows Registry Editor Version 5.00
|
||||
"URL Protocol"=""
|
||||
"NoOpenWith"=-
|
||||
|
||||
[-HKEY_CLASSES_ROOT\ms-gamebar\shell\open\command]
|
||||
[-HKEY_CLASSES_ROOT\ms-gamebarservices\shell\open\command]
|
||||
126
Win11Debloat.ps1
126
Win11Debloat.ps1
@@ -105,6 +105,7 @@ $script:ControlParams = 'WhatIf', 'Confirm', 'Verbose', 'Debug', 'LogPath', 'Sil
|
||||
$script:GuiConsoleOutput = $null
|
||||
$script:GuiConsoleScrollViewer = $null
|
||||
$script:GuiWindow = $null
|
||||
$script:CancelRequested = $false
|
||||
|
||||
# Check if current powershell environment is limited by security policies
|
||||
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") {
|
||||
@@ -598,10 +599,9 @@ function OpenGUI {
|
||||
$window.Close()
|
||||
})
|
||||
|
||||
# Ensure closing the window via any means properly exits the script
|
||||
# Ensure closing the main window stops all execution
|
||||
$window.Add_Closing({
|
||||
Stop-Transcript
|
||||
Exit
|
||||
$script:CancelRequested = $true
|
||||
})
|
||||
|
||||
# Implement window resize functionality
|
||||
@@ -861,6 +861,17 @@ function OpenGUI {
|
||||
return $combo
|
||||
}
|
||||
|
||||
function GetWikiUrlForCategory($category) {
|
||||
if (-not $category) { return 'https://github.com/Raphire/Win11Debloat/wiki/Features' }
|
||||
|
||||
$slug = $category.ToLowerInvariant()
|
||||
$slug = $slug -replace '&', ''
|
||||
$slug = $slug -replace '[^a-z0-9\s-]', ''
|
||||
$slug = $slug -replace '\s', '-'
|
||||
|
||||
return "https://github.com/Raphire/Win11Debloat/wiki/Features#$slug"
|
||||
}
|
||||
|
||||
function GetOrCreateCategoryCard($category) {
|
||||
if (-not $category) { $category = 'Other' }
|
||||
|
||||
@@ -877,10 +888,30 @@ function OpenGUI {
|
||||
$safe = ($category -replace '[^a-zA-Z0-9_]','_')
|
||||
$panel.Name = "Category_{0}_Panel" -f $safe
|
||||
|
||||
$headerRow = New-Object System.Windows.Controls.StackPanel
|
||||
$headerRow.Orientation = 'Horizontal'
|
||||
|
||||
$header = New-Object System.Windows.Controls.TextBlock
|
||||
$header.Text = $category
|
||||
$header.Style = $window.Resources['CategoryHeaderTextBlock']
|
||||
$panel.Children.Add($header) | Out-Null
|
||||
$headerRow.Children.Add($header) | Out-Null
|
||||
|
||||
$helpIcon = New-Object System.Windows.Controls.TextBlock
|
||||
$helpIcon.Text = '(?)'
|
||||
$helpIcon.Style = $window.Resources['CategoryHelpLinkTextStyle']
|
||||
|
||||
$helpBtn = New-Object System.Windows.Controls.Button
|
||||
$helpBtn.Content = $helpIcon
|
||||
$helpBtn.ToolTip = "Open wiki for more info on $category features"
|
||||
$helpBtn.Tag = (GetWikiUrlForCategory -category $category)
|
||||
$helpBtn.Style = $window.Resources['CategoryHelpLinkButtonStyle']
|
||||
$helpBtn.Add_Click({
|
||||
param($sender, $e)
|
||||
if ($sender.Tag) { Start-Process $sender.Tag }
|
||||
})
|
||||
$headerRow.Children.Add($helpBtn) | Out-Null
|
||||
|
||||
$panel.Children.Add($headerRow) | Out-Null
|
||||
|
||||
$border.Child = $panel
|
||||
$target.Children.Add($border) | Out-Null
|
||||
@@ -1710,25 +1741,18 @@ function OpenGUI {
|
||||
try {
|
||||
ExecuteAllChanges
|
||||
|
||||
if (-not $script:Params.ContainsKey("Sysprep") -and -not $script:Params.ContainsKey("User") -and -not $script:Params.ContainsKey("NoRestartExplorer")) {
|
||||
# Ask user if they want to restart Explorer now
|
||||
$result = [System.Windows.MessageBox]::Show(
|
||||
'Would you like to restart the Windows Explorer process now to apply all changes? Some changes may not take effect until a restart is performed.',
|
||||
'Restart Windows Explorer?',
|
||||
[System.Windows.MessageBoxButton]::YesNo,
|
||||
[System.Windows.MessageBoxImage]::Question
|
||||
)
|
||||
|
||||
if ($result -eq [System.Windows.MessageBoxResult]::Yes) {
|
||||
RestartExplorer
|
||||
}
|
||||
else {
|
||||
Write-ToConsole "Explorer process restart was skipped, please manually reboot your PC to apply all changes"
|
||||
}
|
||||
# Check if user wants to restart explorer (from checkbox)
|
||||
$restartExplorerCheckBox = $window.FindName('RestartExplorerCheckBox')
|
||||
if ($restartExplorerCheckBox -and $restartExplorerCheckBox.IsChecked -and -not $script:CancelRequested) {
|
||||
RestartExplorer
|
||||
}
|
||||
|
||||
Write-ToConsole ""
|
||||
Write-ToConsole "All changes have been applied. Please check the output above for any errors."
|
||||
if ($script:CancelRequested) {
|
||||
Write-ToConsole "Script execution was cancelled by the user. Some changes may not have been applied."
|
||||
} else {
|
||||
Write-ToConsole "All changes have been applied. Please check the output above for any errors."
|
||||
}
|
||||
|
||||
$finishBtn.Dispatcher.Invoke([action]{
|
||||
$finishBtn.IsEnabled = $true
|
||||
@@ -1751,6 +1775,33 @@ function OpenGUI {
|
||||
|
||||
LoadAppsIntoMainUI
|
||||
|
||||
# Update Current User label with username
|
||||
if ($userSelectionCombo -and $userSelectionCombo.Items.Count -gt 0) {
|
||||
$currentUserItem = $userSelectionCombo.Items[0]
|
||||
if ($currentUserItem -is [System.Windows.Controls.ComboBoxItem]) {
|
||||
$currentUserItem.Content = "Current User ($(GetUserName))"
|
||||
}
|
||||
}
|
||||
|
||||
# Disable Restart Explorer option if NoRestartExplorer parameter is set
|
||||
$restartExplorerCheckBox = $window.FindName('RestartExplorerCheckBox')
|
||||
if ($restartExplorerCheckBox -and $script:Params.ContainsKey("NoRestartExplorer")) {
|
||||
$restartExplorerCheckBox.IsChecked = $false
|
||||
$restartExplorerCheckBox.IsEnabled = $false
|
||||
}
|
||||
|
||||
# Force Apply Changes To setting if Sysprep or User parameters are set
|
||||
if ($script:Params.ContainsKey("Sysprep")) {
|
||||
$userSelectionCombo.SelectedIndex = 2
|
||||
$userSelectionCombo.IsEnabled = $false
|
||||
}
|
||||
elseif ($script:Params.ContainsKey("User")) {
|
||||
$userSelectionCombo.SelectedIndex = 1
|
||||
$userSelectionCombo.IsEnabled = $false
|
||||
$otherUsernameTextBox.Text = $script:Params.Item("User")
|
||||
$otherUsernameTextBox.IsEnabled = $false
|
||||
}
|
||||
|
||||
UpdateNavigationButtons
|
||||
})
|
||||
|
||||
@@ -2170,6 +2221,10 @@ function RemoveApps {
|
||||
)
|
||||
|
||||
Foreach ($app in $appsList) {
|
||||
if ($script:CancelRequested) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-ToConsole "Attempting to remove $app..."
|
||||
|
||||
# Use WinGet only to remove OneDrive and Edge
|
||||
@@ -2194,10 +2249,21 @@ function RemoveApps {
|
||||
|
||||
If (($app -eq "Microsoft.Edge") -and (Select-String -InputObject $wingetOutput -Pattern "Uninstall failed with exit code")) {
|
||||
Write-ToConsole "Unable to uninstall Microsoft Edge via WinGet" -ForegroundColor Red
|
||||
Write-ToConsole ""
|
||||
|
||||
# Only prompt in CLI mode (not GUI)
|
||||
if (-not $script:GuiConsoleOutput -and $( Read-Host -Prompt "Would you like to forcefully uninstall Microsoft Edge? NOT RECOMMENDED! (y/n)" ) -eq 'y') {
|
||||
if ($script:GuiConsoleOutput) {
|
||||
$result = [System.Windows.MessageBox]::Show(
|
||||
'Unable to uninstall Microsoft Edge via WinGet. Would you like to forcefully uninstall it? NOT RECOMMENDED!',
|
||||
'Force Uninstall Microsoft Edge?',
|
||||
[System.Windows.MessageBoxButton]::YesNo,
|
||||
[System.Windows.MessageBoxImage]::Warning
|
||||
)
|
||||
|
||||
if ($result -eq [System.Windows.MessageBoxResult]::Yes) {
|
||||
Write-ToConsole ""
|
||||
ForceRemoveEdge
|
||||
}
|
||||
}
|
||||
elseif ($( Read-Host -Prompt "Would you like to forcefully uninstall Microsoft Edge? NOT RECOMMENDED! (y/n)" ) -eq 'y') {
|
||||
Write-ToConsole ""
|
||||
ForceRemoveEdge
|
||||
}
|
||||
@@ -2248,7 +2314,7 @@ function ForceRemoveEdge {
|
||||
$hklm = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $regView)
|
||||
$hklm.CreateSubKey('SOFTWARE\Microsoft\EdgeUpdateDev').SetValue('AllowUninstall', '')
|
||||
|
||||
# Create stub (Creating this somehow allows uninstalling Edge)
|
||||
# Create stub (This somehow allows uninstalling Edge)
|
||||
$edgeStub = "$env:SystemRoot\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"
|
||||
New-Item $edgeStub -ItemType Directory | Out-Null
|
||||
New-Item "$edgeStub\MicrosoftEdge.exe" | Out-Null
|
||||
@@ -2290,11 +2356,8 @@ function ForceRemoveEdge {
|
||||
Write-ToConsole "Microsoft Edge was uninstalled"
|
||||
}
|
||||
else {
|
||||
Write-ToConsole ""
|
||||
Write-ToConsole "Error: Unable to forcefully uninstall Microsoft Edge, uninstaller could not be found" -ForegroundColor Red
|
||||
Write-ToConsole "Unable to forcefully uninstall Microsoft Edge, uninstaller could not be found" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-ToConsole ""
|
||||
}
|
||||
|
||||
|
||||
@@ -2907,10 +2970,15 @@ function ExecuteAllChanges {
|
||||
if ($script:Params.ContainsKey("CreateRestorePoint")) {
|
||||
Write-ToConsole "> Attempting to create a system restore point..."
|
||||
CreateSystemRestorePoint
|
||||
Write-ToConsole ""
|
||||
}
|
||||
|
||||
# Execute all parameters
|
||||
foreach ($paramKey in $script:Params.Keys) {
|
||||
if ($script:CancelRequested) {
|
||||
return
|
||||
}
|
||||
|
||||
if ($script:ControlParams -contains $paramKey) {
|
||||
continue
|
||||
}
|
||||
@@ -3002,8 +3070,6 @@ function CreateSystemRestorePoint {
|
||||
Write-ToConsole $result.Message -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
Write-ToConsole ""
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user