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 { } Else {
Write-Status -Types "?", $TweakType -Status $(Invoke-Expression "$CustomMessage") -Warning Write-Status -Types "?", $TweakType -Status $(Invoke-Expression "$CustomMessage") -Warning
} }
Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType $State Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType $State
} }
} }

@ -13,13 +13,14 @@ function Remove-UWPAppx() {
Process { Process {
ForEach ($AppxPackage in $AppxPackages) { ForEach ($AppxPackage in $AppxPackages) {
If ((Get-AppxPackage -AllUsers -Name $AppxPackage) -or (Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $AppxPackage)) { 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 {
Write-Status -Types "?", $TweakType -Status "$AppxPackage was already removed or not found..." -Warning 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 $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" $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 $AppName = Split-Path -Path $WingetOutput -Leaf
Try { Try {
# Method from: https://github.com/microsoft/winget-cli/blob/master/doc/troubleshooting/README.md#machine-wide-provisioning # Method from: https://github.com/microsoft/winget-cli/blob/master/doc/troubleshooting/README.md#machine-wide-provisioning
If ($WingetDepOutput) { If ($WingetDepOutput) {
Write-Status -Types "@" -Status "Trying to install the App (w/ license + dependency): $AppName" -Warning Write-Status -Types "@" -Status "Trying to install the App (w/ dependency): $AppName" -Warning
$InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -LicensePath $WingetLicenseOutput -DependencyPackagePath $WingetDepOutput | Out-Null } $InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -SkipLicense -DependencyPackagePath $WingetDepOutput | Out-Null }
Invoke-Expression "$InstallPackageCommand" Invoke-Expression "$InstallPackageCommand"
} }
Write-Status -Types "@" -Status "Trying to install the App (w/ license): $AppName" -Warning Write-Status -Types "@" -Status "Trying to install the App (no dependency): $AppName" -Warning
$InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -LicensePath $WingetLicenseOutput | Out-Null } $InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -SkipLicense | Out-Null }
Invoke-Expression "$InstallPackageCommand" Invoke-Expression "$InstallPackageCommand"
} Catch { } Catch {
Write-Status -Types "@" -Status "Couldn't install '$AppName' automatically, trying to install the App manually..." -Warning 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 $WingetOutput
Remove-Item -Path $WingetLicenseOutput
} }
} }

@ -54,52 +54,52 @@ function Remove-BloatwareAppsList() {
"MicrosoftTeams" # Microsoft Teams / Preview "MicrosoftTeams" # Microsoft Teams / Preview
# 3rd party Apps # 3rd party Apps
"*ACGMediaPlayer*" "ACGMediaPlayer"
"*ActiproSoftwareLLC*" "ActiproSoftwareLLC"
"*AdobePhotoshopExpress*" # Adobe Photoshop Express "AdobePhotoshopExpress" # Adobe Photoshop Express
"*Amazon.com.Amazon*" # Amazon Shop "Amazon.com.Amazon" # Amazon Shop
"*Asphalt8Airborne*" # Asphalt 8 Airbone "Asphalt8Airborne" # Asphalt 8 Airbone
"*AutodeskSketchBook*" "AutodeskSketchBook"
"*BubbleWitch3Saga*" # Bubble Witch 3 Saga "BubbleWitch3Saga" # Bubble Witch 3 Saga
"*CaesarsSlotsFreeCasino*" "CaesarsSlotsFreeCasino"
"*CandyCrush*" # Candy Crush "CandyCrush" # Candy Crush
"*COOKINGFEVER*" "COOKINGFEVER"
"*CyberLinkMediaSuiteEssentials*" "CyberLinkMediaSuiteEssentials"
"*DisneyMagicKingdoms*" "DisneyMagicKingdoms"
"*Dolby*" # Dolby Products (Like Atmos) "Dolby" # Dolby Products (Like Atmos)
"*DrawboardPDF*" "DrawboardPDF"
"*Duolingo-LearnLanguagesforFree*" # Duolingo "Duolingo-LearnLanguagesforFree" # Duolingo
"*EclipseManager*" "EclipseManager"
"*Facebook*" # Facebook "Facebook" # Facebook
"*FarmVille2CountryEscape*" "FarmVille2CountryEscape"
"*FitbitCoach*" "FitbitCoach"
"*Flipboard*" # Flipboard "Flipboard" # Flipboard
"*HiddenCity*" "HiddenCity"
"*Hulu*" "Hulu"
"*iHeartRadio*" "iHeartRadio"
"*Keeper*" "Keeper"
"*LinkedInforWindows*" "LinkedInforWindows"
"*MarchofEmpires*" "MarchofEmpires"
"*Netflix*" # Netflix "Netflix" # Netflix
"*NYTCrossword*" "NYTCrossword"
"*OneCalendar*" "OneCalendar"
"*PandoraMediaInc*" "PandoraMediaInc"
"*PhototasticCollage*" "PhototasticCollage"
"*PicsArt-PhotoStudio*" "PicsArt-PhotoStudio"
"*Plex*" # Plex "Plex" # Plex
"*PolarrPhotoEditorAcademicEdition*" "PolarrPhotoEditorAcademicEdition"
"*RoyalRevolt*" # Royal Revolt "RoyalRevolt" # Royal Revolt
"*Shazam*" "Shazam"
"*Sidia.LiveWallpaper*" # Live Wallpaper "Sidia.LiveWallpaper" # Live Wallpaper
"*SlingTV*" "SlingTV"
"*Speed Test*" "Speed Test"
"*Sway*" "Sway"
"*TuneInRadio*" "TuneInRadio"
"*Twitter*" # Twitter "Twitter" # Twitter
"*Viber*" "Viber"
"*WinZipUniversal*" "WinZipUniversal"
"*Wunderlist*" "Wunderlist"
"*XING*" "XING"
# Apps which other apps depend on # Apps which other apps depend on
"Microsoft.Advertising.Xaml" "Microsoft.Advertising.Xaml"
@ -137,7 +137,7 @@ function Remove-BloatwareAppsList() {
# [DIY] Common Streaming services # [DIY] Common Streaming services
#"*SpotifyMusic*" # Spotify #"SpotifyMusic" # Spotify
# [DIY] Can't be reinstalled # [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\"title-templates.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\debloat-helper\"remove-item-verified.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\"set-item-property-verified.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\debloat-helper\"uwp-appx-handler.psm1"
function Main() { 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." $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() { function Remove-MSEdge() {
$PathToLMEdgeUpdate = "HKLM:\SOFTWARE\Microsoft\EdgeUpdate" $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")) { 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) { 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..." 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 Write-Status -Types "?" -Status "EdgeCore folder does not exist anymore..." -Warning
} }
Remove-UWPAppx -AppxPackages "Microsoft.MicrosoftEdge"
Write-Status -Types "@" -Status "Preventing Edge from reinstalling..." Write-Status -Types "@" -Status "Preventing Edge from reinstalling..."
Set-ItemPropertyVerified -Path "$PathToLMEdgeUpdate" -Name "DoNotUpdateToEdgeWithChromium" -Type DWord -Value 1 Set-ItemPropertyVerified -Path "$PathToLMEdgeUpdate" -Name "DoNotUpdateToEdgeWithChromium" -Type DWord -Value 1

Loading…
Cancel
Save