mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-08-21 23:26:42 +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.
|
||||
#>
|
||||
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..."
|
||||
|
||||
$regView = [Microsoft.Win32.RegistryView]::Registry32
|
||||
|
||||
@@ -69,6 +69,11 @@ function Invoke-FeatureApply {
|
||||
Remove-SelectedApps $appsList
|
||||
return
|
||||
}
|
||||
'ForceRemoveEdge' {
|
||||
Write-Host "> $applyText..."
|
||||
Invoke-ForceRemoveEdge
|
||||
return
|
||||
}
|
||||
'DisableWidgets' {
|
||||
Write-Host "> $applyText..."
|
||||
# Stop widgets related processes before removing the app packages to prevent potential issues
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
BeforeAll {
|
||||
function Import-RegistryFile { param($Message, $path) }
|
||||
function Remove-SelectedApps { param($Apps) }
|
||||
function Invoke-ForceRemoveEdge {}
|
||||
function Disable-TelemetryScheduledTasks {}
|
||||
function Enable-TelemetryScheduledTasks {}
|
||||
function Generate-AppsList { @() }
|
||||
@@ -51,6 +52,7 @@ Describe 'Invoke-FeatureApply' {
|
||||
RemoveApps = [PSCustomObject]@{ ApplyText = 'Remove apps'; RegistryKey = '' }
|
||||
RemoveGamingApps = [PSCustomObject]@{ ApplyText = 'Remove gaming'; RegistryKey = '' }
|
||||
RemoveHPApps = [PSCustomObject]@{ ApplyText = 'Remove HP'; RegistryKey = '' }
|
||||
ForceRemoveEdge = [PSCustomObject]@{ ApplyText = 'Force remove Edge'; RegistryKey = '' }
|
||||
DisableWidgets = [PSCustomObject]@{ ApplyText = 'Disable widgets'; RegistryKey = '' }
|
||||
EnableWindowsSandbox = [PSCustomObject]@{ ApplyText = 'Enable Sandbox'; RegistryKey = '' }
|
||||
EnableWindowsSubsystemForLinux = [PSCustomObject]@{ ApplyText = 'Enable WSL'; RegistryKey = '' }
|
||||
@@ -62,6 +64,7 @@ Describe 'Invoke-FeatureApply' {
|
||||
}
|
||||
Mock Import-RegistryFile {}
|
||||
Mock Remove-SelectedApps {}
|
||||
Mock Invoke-ForceRemoveEdge {}
|
||||
Mock Disable-TelemetryScheduledTasks {}
|
||||
Mock Generate-AppsList { @() }
|
||||
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 ',' }
|
||||
}
|
||||
|
||||
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 @(
|
||||
@{ FeatureId = 'RemoveGamingApps'; MinimumCount = 3; ExpectedApp = 'Microsoft.GamingApp' }
|
||||
@{ FeatureId = 'RemoveHPApps'; MinimumCount = 10; ExpectedApp = 'AD2F1837.myHP' }
|
||||
|
||||
Reference in New Issue
Block a user