refactor(uwp): Verify App before and proceed to next

- Add wildcards inside lib, so no need to add on each App

- Add MSEdge app to remove-msedge.ps1
- Remove License downloading within winget install 2nd method
main
Plínio Larrubia 2 years ago committed by Plínio Larrubia
parent 7a8039de9f
commit 27b5ffdc49
No known key found for this signature in database
GPG Key ID: 057B0A87CB137C69

@ -39,6 +39,7 @@ function Set-ServiceStartup() {
} Else {
Write-Status -Types "?", $TweakType -Status $(Invoke-Expression "$CustomMessage") -Warning
}
Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType $State
}
}

@ -13,13 +13,14 @@ function Remove-UWPAppx() {
Process {
ForEach ($AppxPackage in $AppxPackages) {
If ((Get-AppxPackage -AllUsers -Name $AppxPackage) -or (Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $AppxPackage)) {
Write-Status -Types "-", $TweakType -Status "Trying to remove $AppxPackage from ALL users..."
Get-AppxPackage -AllUsers -Name $AppxPackage | Remove-AppxPackage # App
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $AppxPackage | Remove-AppxProvisionedPackage -Online -AllUsers # Payload
} Else {
If (!((Get-AppxPackage -AllUsers -Name "*$AppxPackage*") -or (Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like "*$AppxPackage*"))) {
Write-Status -Types "?", $TweakType -Status "$AppxPackage was already removed or not found..." -Warning
Continue
}
Write-Status -Types "-", $TweakType -Status "Trying to remove $AppxPackage from ALL users..."
Get-AppxPackage -AllUsers -Name "*$AppxPackage*" | Remove-AppxPackage -AllUsers
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like "*$AppxPackage*" | Remove-AppxProvisionedPackage -Online -AllUsers
}
}
}

@ -123,19 +123,18 @@ function Main() {
{
$WingetDepOutput = Install-WingetDependency
$WingetOutput = Get-APIFile -URI "https://api.github.com/repos/microsoft/winget-cli/releases/latest" -ObjectProperty "assets" -FileNameLike "*.msixbundle" -PropertyValue "browser_download_url" -OutputFile "Microsoft.DesktopAppInstaller.msixbundle"
$WingetLicenseOutput = Get-APIFile -URI "https://api.github.com/repos/microsoft/winget-cli/releases/latest" -ObjectProperty "assets" -FileNameLike "*License*.xml" -PropertyValue "browser_download_url" -OutputFile "WingetLicense.xml"
$AppName = Split-Path -Path $WingetOutput -Leaf
Try {
# Method from: https://github.com/microsoft/winget-cli/blob/master/doc/troubleshooting/README.md#machine-wide-provisioning
If ($WingetDepOutput) {
Write-Status -Types "@" -Status "Trying to install the App (w/ license + dependency): $AppName" -Warning
$InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -LicensePath $WingetLicenseOutput -DependencyPackagePath $WingetDepOutput | Out-Null }
Write-Status -Types "@" -Status "Trying to install the App (w/ dependency): $AppName" -Warning
$InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -SkipLicense -DependencyPackagePath $WingetDepOutput | Out-Null }
Invoke-Expression "$InstallPackageCommand"
}
Write-Status -Types "@" -Status "Trying to install the App (w/ license): $AppName" -Warning
$InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -LicensePath $WingetLicenseOutput | Out-Null }
Write-Status -Types "@" -Status "Trying to install the App (no dependency): $AppName" -Warning
$InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -SkipLicense | Out-Null }
Invoke-Expression "$InstallPackageCommand"
} Catch {
Write-Status -Types "@" -Status "Couldn't install '$AppName' automatically, trying to install the App manually..." -Warning
@ -143,7 +142,6 @@ function Main() {
}
Remove-Item -Path $WingetOutput
Remove-Item -Path $WingetLicenseOutput
}
}

@ -54,52 +54,52 @@ function Remove-BloatwareAppsList() {
"MicrosoftTeams" # Microsoft Teams / Preview
# 3rd party Apps
"*ACGMediaPlayer*"
"*ActiproSoftwareLLC*"
"*AdobePhotoshopExpress*" # Adobe Photoshop Express
"*Amazon.com.Amazon*" # Amazon Shop
"*Asphalt8Airborne*" # Asphalt 8 Airbone
"*AutodeskSketchBook*"
"*BubbleWitch3Saga*" # Bubble Witch 3 Saga
"*CaesarsSlotsFreeCasino*"
"*CandyCrush*" # Candy Crush
"*COOKINGFEVER*"
"*CyberLinkMediaSuiteEssentials*"
"*DisneyMagicKingdoms*"
"*Dolby*" # Dolby Products (Like Atmos)
"*DrawboardPDF*"
"*Duolingo-LearnLanguagesforFree*" # Duolingo
"*EclipseManager*"
"*Facebook*" # Facebook
"*FarmVille2CountryEscape*"
"*FitbitCoach*"
"*Flipboard*" # Flipboard
"*HiddenCity*"
"*Hulu*"
"*iHeartRadio*"
"*Keeper*"
"*LinkedInforWindows*"
"*MarchofEmpires*"
"*Netflix*" # Netflix
"*NYTCrossword*"
"*OneCalendar*"
"*PandoraMediaInc*"
"*PhototasticCollage*"
"*PicsArt-PhotoStudio*"
"*Plex*" # Plex
"*PolarrPhotoEditorAcademicEdition*"
"*RoyalRevolt*" # Royal Revolt
"*Shazam*"
"*Sidia.LiveWallpaper*" # Live Wallpaper
"*SlingTV*"
"*Speed Test*"
"*Sway*"
"*TuneInRadio*"
"*Twitter*" # Twitter
"*Viber*"
"*WinZipUniversal*"
"*Wunderlist*"
"*XING*"
"ACGMediaPlayer"
"ActiproSoftwareLLC"
"AdobePhotoshopExpress" # Adobe Photoshop Express
"Amazon.com.Amazon" # Amazon Shop
"Asphalt8Airborne" # Asphalt 8 Airbone
"AutodeskSketchBook"
"BubbleWitch3Saga" # Bubble Witch 3 Saga
"CaesarsSlotsFreeCasino"
"CandyCrush" # Candy Crush
"COOKINGFEVER"
"CyberLinkMediaSuiteEssentials"
"DisneyMagicKingdoms"
"Dolby" # Dolby Products (Like Atmos)
"DrawboardPDF"
"Duolingo-LearnLanguagesforFree" # Duolingo
"EclipseManager"
"Facebook" # Facebook
"FarmVille2CountryEscape"
"FitbitCoach"
"Flipboard" # Flipboard
"HiddenCity"
"Hulu"
"iHeartRadio"
"Keeper"
"LinkedInforWindows"
"MarchofEmpires"
"Netflix" # Netflix
"NYTCrossword"
"OneCalendar"
"PandoraMediaInc"
"PhototasticCollage"
"PicsArt-PhotoStudio"
"Plex" # Plex
"PolarrPhotoEditorAcademicEdition"
"RoyalRevolt" # Royal Revolt
"Shazam"
"Sidia.LiveWallpaper" # Live Wallpaper
"SlingTV"
"Speed Test"
"Sway"
"TuneInRadio"
"Twitter" # Twitter
"Viber"
"WinZipUniversal"
"Wunderlist"
"XING"
# Apps which other apps depend on
"Microsoft.Advertising.Xaml"
@ -137,7 +137,7 @@ function Remove-BloatwareAppsList() {
# [DIY] Common Streaming services
#"*SpotifyMusic*" # Spotify
#"SpotifyMusic" # Spotify
# [DIY] Can't be reinstalled

@ -2,6 +2,7 @@ Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"show-dialog-window.psm1
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\debloat-helper\"remove-item-verified.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\debloat-helper\"set-item-property-verified.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\debloat-helper\"uwp-appx-handler.psm1"
function Main() {
$Ask = "Are you sure you want to remove Microsoft Edge from Windows?`nYou can reinstall it anytime.`nNote: all users logged in will remain."
@ -22,6 +23,9 @@ function Main() {
function Remove-MSEdge() {
$PathToLMEdgeUpdate = "HKLM:\SOFTWARE\Microsoft\EdgeUpdate"
Write-Status -Types "@" -Status "Stopping all 'msedge' processes before uninstalling..."
Get-Process -Name msedge | Stop-Process -PassThru -Force
If ((Test-Path -Path "$env:SystemDrive\Program Files (x86)\Microsoft\Edge\Application") -or (Test-Path -Path "$env:SystemDrive\Program Files (x86)\Microsoft\EdgeWebView\Application")) {
ForEach ($FullName in (Get-ChildItem -Path "$env:SystemDrive\Program Files (x86)\Microsoft\Edge*\Application\*\Installer\setup.exe").FullName) {
Write-Status -Types "@" -Status "Uninstalling MS Edge from $FullName..."
@ -40,6 +44,8 @@ function Remove-MSEdge() {
Write-Status -Types "?" -Status "EdgeCore folder does not exist anymore..." -Warning
}
Remove-UWPAppx -AppxPackages "Microsoft.MicrosoftEdge"
Write-Status -Types "@" -Status "Preventing Edge from reinstalling..."
Set-ItemPropertyVerified -Path "$PathToLMEdgeUpdate" -Name "DoNotUpdateToEdgeWithChromium" -Type DWord -Value 1

Loading…
Cancel
Save