mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-08-22 07:36:25 +00:00
Fix ForceRemoveEdge switch (#736)
This commit is contained in:
@@ -3,6 +3,12 @@
|
|||||||
Forcefully uninstalls Microsoft Edge and removes its leftover shortcuts and autostart entries.
|
Forcefully uninstalls Microsoft Edge and removes its leftover shortcuts and autostart entries.
|
||||||
#>
|
#>
|
||||||
function Invoke-ForceRemoveEdge {
|
function Invoke-ForceRemoveEdge {
|
||||||
|
if ($script:Params.ContainsKey("WhatIf")) {
|
||||||
|
Write-Host "[WhatIf] Forcefully uninstall Microsoft Edge" -ForegroundColor Cyan
|
||||||
|
Write-Host ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "> Forcefully uninstalling Microsoft Edge..."
|
Write-Host "> Forcefully uninstalling Microsoft Edge..."
|
||||||
|
|
||||||
$regView = [Microsoft.Win32.RegistryView]::Registry32
|
$regView = [Microsoft.Win32.RegistryView]::Registry32
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ function Invoke-FeatureApply {
|
|||||||
Remove-SelectedApps $appsList
|
Remove-SelectedApps $appsList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
'ForceRemoveEdge' {
|
||||||
|
Write-Host "> $applyText..."
|
||||||
|
Invoke-ForceRemoveEdge
|
||||||
|
return
|
||||||
|
}
|
||||||
'DisableWidgets' {
|
'DisableWidgets' {
|
||||||
Write-Host "> $applyText..."
|
Write-Host "> $applyText..."
|
||||||
# Stop widgets related processes before removing the app packages to prevent potential issues
|
# Stop widgets related processes before removing the app packages to prevent potential issues
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
BeforeAll {
|
BeforeAll {
|
||||||
function Import-RegistryFile { param($Message, $path) }
|
function Import-RegistryFile { param($Message, $path) }
|
||||||
function Remove-SelectedApps { param($Apps) }
|
function Remove-SelectedApps { param($Apps) }
|
||||||
|
function Invoke-ForceRemoveEdge {}
|
||||||
function Disable-TelemetryScheduledTasks {}
|
function Disable-TelemetryScheduledTasks {}
|
||||||
function Enable-TelemetryScheduledTasks {}
|
function Enable-TelemetryScheduledTasks {}
|
||||||
function Generate-AppsList { @() }
|
function Generate-AppsList { @() }
|
||||||
@@ -51,6 +52,7 @@ Describe 'Invoke-FeatureApply' {
|
|||||||
RemoveApps = [PSCustomObject]@{ ApplyText = 'Remove apps'; RegistryKey = '' }
|
RemoveApps = [PSCustomObject]@{ ApplyText = 'Remove apps'; RegistryKey = '' }
|
||||||
RemoveGamingApps = [PSCustomObject]@{ ApplyText = 'Remove gaming'; RegistryKey = '' }
|
RemoveGamingApps = [PSCustomObject]@{ ApplyText = 'Remove gaming'; RegistryKey = '' }
|
||||||
RemoveHPApps = [PSCustomObject]@{ ApplyText = 'Remove HP'; RegistryKey = '' }
|
RemoveHPApps = [PSCustomObject]@{ ApplyText = 'Remove HP'; RegistryKey = '' }
|
||||||
|
ForceRemoveEdge = [PSCustomObject]@{ ApplyText = 'Force remove Edge'; RegistryKey = '' }
|
||||||
DisableWidgets = [PSCustomObject]@{ ApplyText = 'Disable widgets'; RegistryKey = '' }
|
DisableWidgets = [PSCustomObject]@{ ApplyText = 'Disable widgets'; RegistryKey = '' }
|
||||||
EnableWindowsSandbox = [PSCustomObject]@{ ApplyText = 'Enable Sandbox'; RegistryKey = '' }
|
EnableWindowsSandbox = [PSCustomObject]@{ ApplyText = 'Enable Sandbox'; RegistryKey = '' }
|
||||||
EnableWindowsSubsystemForLinux = [PSCustomObject]@{ ApplyText = 'Enable WSL'; RegistryKey = '' }
|
EnableWindowsSubsystemForLinux = [PSCustomObject]@{ ApplyText = 'Enable WSL'; RegistryKey = '' }
|
||||||
@@ -62,6 +64,7 @@ Describe 'Invoke-FeatureApply' {
|
|||||||
}
|
}
|
||||||
Mock Import-RegistryFile {}
|
Mock Import-RegistryFile {}
|
||||||
Mock Remove-SelectedApps {}
|
Mock Remove-SelectedApps {}
|
||||||
|
Mock Invoke-ForceRemoveEdge {}
|
||||||
Mock Disable-TelemetryScheduledTasks {}
|
Mock Disable-TelemetryScheduledTasks {}
|
||||||
Mock Generate-AppsList { @() }
|
Mock Generate-AppsList { @() }
|
||||||
Mock Get-FriendlyTargetUserName { 'current user' }
|
Mock Get-FriendlyTargetUserName { 'current user' }
|
||||||
@@ -116,6 +119,14 @@ Describe 'Invoke-FeatureApply' {
|
|||||||
Should -Invoke Remove-SelectedApps -Times 1 -Exactly -ParameterFilter { @($Apps) -join ',' -eq $ExpectedApps -join ',' }
|
Should -Invoke Remove-SelectedApps -Times 1 -Exactly -ParameterFilter { @($Apps) -join ',' -eq $ExpectedApps -join ',' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It 'forcefully removes Edge when requested' {
|
||||||
|
Invoke-FeatureApply -FeatureId 'ForceRemoveEdge'
|
||||||
|
|
||||||
|
Should -Invoke Invoke-ForceRemoveEdge -Times 1 -Exactly
|
||||||
|
Should -Invoke Import-RegistryFile -Times 0 -Exactly
|
||||||
|
Should -Invoke Remove-SelectedApps -Times 0 -Exactly
|
||||||
|
}
|
||||||
|
|
||||||
It 'uses the expected static app list for <FeatureId>' -ForEach @(
|
It 'uses the expected static app list for <FeatureId>' -ForEach @(
|
||||||
@{ FeatureId = 'RemoveGamingApps'; MinimumCount = 3; ExpectedApp = 'Microsoft.GamingApp' }
|
@{ FeatureId = 'RemoveGamingApps'; MinimumCount = 3; ExpectedApp = 'Microsoft.GamingApp' }
|
||||||
@{ FeatureId = 'RemoveHPApps'; MinimumCount = 10; ExpectedApp = 'AD2F1837.myHP' }
|
@{ FeatureId = 'RemoveHPApps'; MinimumCount = 10; ExpectedApp = 'AD2F1837.myHP' }
|
||||||
|
|||||||
Reference in New Issue
Block a user