Added option to forcefully remove edge (#82)

Additionally:
* Added extra check to Get.ps1 to prevent error if user cancels UAC prompt 
* Removed Dolby from appslist (#78)
This commit is contained in:
Jeffrey
2024-07-02 18:51:00 +02:00
committed by GitHub
parent 6614cdfe8b
commit 6049800f10
4 changed files with 117 additions and 17 deletions

View File

@@ -52,7 +52,6 @@ COOKINGFEVER
CyberLinkMediaSuiteEssentials CyberLinkMediaSuiteEssentials
DisneyMagicKingdoms DisneyMagicKingdoms
Disney Disney
Dolby
DrawboardPDF DrawboardPDF
Duolingo-LearnLanguagesforFree Duolingo-LearnLanguagesforFree
EclipseManager EclipseManager

View File

@@ -9,6 +9,7 @@ param (
[switch]$RemoveCommApps, [switch]$RemoveCommApps,
[switch]$RemoveDevApps, [switch]$RemoveDevApps,
[switch]$RemoveW11Outlook, [switch]$RemoveW11Outlook,
[switch]$ForceRemoveEdge,
[switch]$DisableDVR, [switch]$DisableDVR,
[switch]$DisableTelemetry, [switch]$DisableTelemetry,
[switch]$DisableBingSearches, [switch]$DisableBing, [switch]$DisableBingSearches, [switch]$DisableBing,
@@ -81,7 +82,11 @@ Write-Output "> Running Win11Debloat..."
# Run Win11Debloat script with the provided arguments # Run Win11Debloat script with the provided arguments
$debloatProcess = Start-Process powershell.exe -PassThru -ArgumentList "-executionpolicy bypass -File $env:TEMP\Win11Debloat\Win11Debloat-master\Win11Debloat.ps1 $arguments" -Verb RunAs $debloatProcess = Start-Process powershell.exe -PassThru -ArgumentList "-executionpolicy bypass -File $env:TEMP\Win11Debloat\Win11Debloat-master\Win11Debloat.ps1 $arguments" -Verb RunAs
$debloatProcess.WaitForExit()
# Wait for the process to finish before continuing
if($debloatProcess -ne $null) {
$debloatProcess.WaitForExit()
}
Write-Output "" Write-Output ""
Write-Output "> Cleaning up..." Write-Output "> Cleaning up..."

View File

@@ -306,6 +306,7 @@ The quick and advanced method support parameters to tailor the behaviour of the
| -RemoveW11Outlook | Remove the new Outlook for Windows app. | | -RemoveW11Outlook | Remove the new Outlook for Windows app. |
| -RemoveDevApps | Remove developer-related apps such as Remote Desktop, DevHome and Power Automate. | | -RemoveDevApps | Remove developer-related apps such as Remote Desktop, DevHome and Power Automate. |
| -RemoveGamingApps | Remove the Xbox App and Xbox Gamebar. | | -RemoveGamingApps | Remove the Xbox App and Xbox Gamebar. |
| -ForceRemoveEdge | Forcefully remove Microsoft Edge. NOT RECOMMENDED! |
| -DisableDVR | Disable Xbox game/screen recording feature & stop gaming overlay popups. | | -DisableDVR | Disable Xbox game/screen recording feature & stop gaming overlay popups. |
| -ClearStart | Remove all pinned apps from start for the current user (Windows 11 update 22H2 or later only) | | -ClearStart | Remove all pinned apps from start for the current user (Windows 11 update 22H2 or later only) |
| -ClearStartAllUsers | Remove all pinned apps from start for all existing and new users. (Windows 11 update 22H2 or later only) | | -ClearStartAllUsers | Remove all pinned apps from start for all existing and new users. (Windows 11 update 22H2 or later only) |

View File

@@ -12,6 +12,7 @@ param (
[switch]$RemoveCommApps, [switch]$RemoveCommApps,
[switch]$RemoveDevApps, [switch]$RemoveDevApps,
[switch]$RemoveW11Outlook, [switch]$RemoveW11Outlook,
[switch]$ForceRemoveEdge,
[switch]$DisableDVR, [switch]$DisableDVR,
[switch]$DisableTelemetry, [switch]$DisableTelemetry,
[switch]$DisableBingSearches, [switch]$DisableBing, [switch]$DisableBingSearches, [switch]$DisableBing,
@@ -44,7 +45,7 @@ param (
# Show error if current powershell environment does not have LanguageMode set to FullLanguage # Show error if current powershell environment does not have LanguageMode set to FullLanguage
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") { if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") {
Write-Host "Error: Win11Debloat is unable to run on your system. Powershell execution is restricted by security policies" -ForegroundColor Red Write-Host "Error: Win11Debloat is unable to run on your system, powershell execution is restricted by security policies" -ForegroundColor Red
Write-Output "" Write-Output ""
Write-Output "Press enter to exit..." Write-Output "Press enter to exit..."
Read-Host | Out-Null Read-Host | Out-Null
@@ -187,18 +188,12 @@ function ShowAppSelectionForm {
if ($appString.length -gt 0) { if ($appString.length -gt 0) {
if ($onlyInstalledCheckBox.Checked) { if ($onlyInstalledCheckBox.Checked) {
# onlyInstalledCheckBox is checked, check if app is installed before adding it to selectionBox # onlyInstalledCheckBox is checked, check if app is installed before adding it to selectionBox
if ($listOfApps -like ("*$appString*")) { if (-not ($listOfApps -like ("*$appString*")) -and -not (Get-AppxPackage -Name $app)) {
$installed = "installed" # App is not installed, continue with next item
continue
} }
elseif (($appString -eq "Microsoft.Edge") -and ($listOfApps -like "* XPFFTQ037JWMHS *")) { if (($appString -eq "Microsoft.Edge") -and -not ($listOfApps -like "* Microsoft.Edge *")) {
$installed = "installed" # App is not installed, continue with next item
}
else {
$installed = Get-AppxPackage -Name $app
}
if ($installed.length -eq 0) {
# App is not installed, continue to next item without adding this app to the selectionBox
continue continue
} }
} }
@@ -350,7 +345,16 @@ function RemoveApps {
} }
else { else {
# Uninstall app via winget # Uninstall app via winget
winget uninstall --accept-source-agreements --disable-interactivity --id $app Strip-Progress -ScriptBlock { winget uninstall --accept-source-agreements --disable-interactivity --id $app } | Tee-Object -Variable wingetOutput
If (($app -eq "Microsoft.Edge") -and (Select-String -InputObject $wingetOutput -Pattern "93")) {
Write-Host "Error: Unable to uninstall Microsoft Edge via Winget" -ForegroundColor Red
Write-Output ""
if ($( Read-Host -Prompt "Would you like to forcefully uninstall Edge? NOT RECOMMENDED! (y/n)" ) -eq 'y') {
ForceRemoveEdge
}
}
} }
} }
else { else {
@@ -374,6 +378,93 @@ function RemoveApps {
} }
function ForceRemoveEdge {
# Based on work from loadstring1 & ave9858
Write-Output ""
Write-Output "> Forcefully uninstalling Microsoft Edge..."
$regView = [Microsoft.Win32.RegistryView]::Registry32
$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)
$edgeStub = "$env:SystemRoot\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"
New-Item $edgeStub -ItemType Directory | Out-Null
New-Item "$edgeStub\MicrosoftEdge.exe" | Out-Null
# Remove edge
$uninstallRegKey = $hklm.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge')
if($uninstallRegKey -ne $null) {
Write-Output "Running uninstaller..."
$uninstallString = $uninstallRegKey.GetValue('UninstallString') + ' --force-uninstall'
Start-Process cmd.exe "/c $uninstallString" -WindowStyle Hidden -Wait
Write-Output "Removing leftover files..."
$appdata = $([Environment]::GetFolderPath('ApplicationData'))
$edgePaths = @(
"$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk",
"$env:APPDATA\Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk",
"$env:APPDATA\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Microsoft Edge.lnk",
"$env:PUBLIC\Desktop\Microsoft Edge.lnk",
"$env:USERPROFILE\Desktop\Microsoft Edge.lnk",
"$appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Tombstones\Microsoft Edge.lnk",
"$appdata\Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk",
"$edgeStub"
)
foreach ($path in $edgePaths){
if (Test-Path -Path $path) {
Remove-Item -Path $path -Force -Recurse -ErrorAction SilentlyContinue
Write-Host " Removed $path" -ForegroundColor DarkGray
}
}
Write-Output "Cleaning up registry..."
# Remove ms edge from autostart
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "MicrosoftEdgeAutoLaunch_A9F6DCE4ABADF4F51CF45CD7129E3C6C" /f *>$null
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "Microsoft Edge Update" /f *>$null
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" /v "MicrosoftEdgeAutoLaunch_A9F6DCE4ABADF4F51CF45CD7129E3C6C" /f *>$null
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" /v "Microsoft Edge Update" /f *>$null
Write-Output "Microsoft Edge was uninstalled"
}
else {
Write-Output ""
Write-Host "Error: Unable to forcefully uninstall Microsoft Edge, uninstaller could not be found" -ForegroundColor Red
}
Write-Output ""
}
# Execute provided command and strips progress spinners/bars from console output
function Strip-Progress {
param(
[ScriptBlock]$ScriptBlock
)
# Regex pattern to match spinner characters and progress bar patterns
$progressPattern = 'Γû[Æê]|^\s+[-\\|/]\s+$'
# Corrected regex pattern for size formatting, ensuring proper capture groups are utilized
$sizePattern = '(\d+(\.\d{1,2})?)\s+(B|KB|MB|GB|TB|PB) /\s+(\d+(\.\d{1,2})?)\s+(B|KB|MB|GB|TB|PB)'
& $ScriptBlock 2>&1 | ForEach-Object {
if ($_ -is [System.Management.Automation.ErrorRecord]) {
"ERROR: $($_.Exception.Message)"
} else {
$line = $_ -replace $progressPattern, '' -replace $sizePattern, ''
if (-not ([string]::IsNullOrWhiteSpace($line)) -and -not ($line.StartsWith(' '))) {
$line
}
}
}
}
# Import & execute regfile # Import & execute regfile
function RegImport { function RegImport {
param ( param (
@@ -1036,14 +1127,14 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPP
Write-Output "" Write-Output ""
Write-Output "Press enter to remove the selected apps or press CTRL+C to quit..." Write-Output "Press enter to remove the selected apps or press CTRL+C to quit..."
Read-Host | Out-Null Read-Host | Out-Null
PrintHeader "App Removal"
} }
} }
else { else {
Write-Host "Selection was cancelled, no apps have been removed!" -ForegroundColor Red Write-Host "Selection was cancelled, no apps have been removed!" -ForegroundColor Red
}
Write-Output "" Write-Output ""
} }
}
# Load custom options selection from the "SavedSettings" file # Load custom options selection from the "SavedSettings" file
'4' { '4' {
@@ -1179,6 +1270,10 @@ else {
continue continue
} }
"ForceRemoveEdge" {
ForceRemoveEdge
continue
}
'DisableDVR' { 'DisableDVR' {
RegImport "> Disabling Xbox game/screen recording..." "Disable_DVR.reg" RegImport "> Disabling Xbox game/screen recording..." "Disable_DVR.reg"
continue continue