Browse Source

use `dism.exe` to force remove certain windows components

close #12
close #17
pull/17/merge
Alex Hirsch 9 years ago
parent
commit
4d303e3218
  1. 55
      scripts/remove-default-apps.ps1

55
scripts/remove-default-apps.ps1

@ -2,6 +2,12 @@
# This script removes unwanted Apps that come with Windows. If you do not want # This script removes unwanted Apps that come with Windows. If you do not want
# to remove certain Apps comment out the corresponding lines below. # to remove certain Apps comment out the corresponding lines below.
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\reg-helper.psm1
echo "Elevating priviledges for this process"
do {} until (Elevate-Privileges SeTakeOwnershipPrivilege)
echo "Uninstalling default apps"
$apps = @( $apps = @(
# default Windows 10 apps # default Windows 10 apps
"Microsoft.3DBuilder" "Microsoft.3DBuilder"
@ -11,13 +17,11 @@ $apps = @(
"Microsoft.BingSports" "Microsoft.BingSports"
"Microsoft.BingWeather" "Microsoft.BingWeather"
"Microsoft.Getstarted" "Microsoft.Getstarted"
#"Microsoft.MicrosoftEdge"
"Microsoft.MicrosoftOfficeHub" "Microsoft.MicrosoftOfficeHub"
"Microsoft.MicrosoftSolitaireCollection" "Microsoft.MicrosoftSolitaireCollection"
"Microsoft.Office.OneNote" "Microsoft.Office.OneNote"
"Microsoft.People" "Microsoft.People"
"Microsoft.SkypeApp" "Microsoft.SkypeApp"
"Microsoft.Windows.Cortana"
"Microsoft.Windows.Photos" "Microsoft.Windows.Photos"
"Microsoft.WindowsAlarms" "Microsoft.WindowsAlarms"
"Microsoft.WindowsCalculator" "Microsoft.WindowsCalculator"
@ -37,25 +41,50 @@ $apps = @(
"Microsoft.MinecraftUWP" "Microsoft.MinecraftUWP"
"ShazamEntertainmentLtd.Shazam" "ShazamEntertainmentLtd.Shazam"
"king.com.CandyCrushSaga" "king.com.CandyCrushSaga"
# apps which cannot be removed using Remove-AppxPackage
#"Microsoft.BioEnrollment"
#"Microsoft.MicrosoftEdge"
#"Microsoft.Windows.Cortana"
#"Microsoft.WindowsFeedback"
#"Microsoft.XboxGameCallableUI"
#"Microsoft.XboxIdentityProvider"
#"Windows.ContactSupport"
) )
echo "Uninstalling default apps"
foreach ($app in $apps) { foreach ($app in $apps) {
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -ErrorAction SilentlyContinue Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
Get-AppXProvisionedPackage -Online | Get-AppXProvisionedPackage -Online |
where DisplayName -EQ $app | where DisplayName -EQ $app |
Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue Remove-AppxProvisionedPackage -Online
} }
echo "Renaming unremovable apps" echo "Force removing system apps"
$apps = @( $needles = @(
"Microsoft.BioEnrollment_cw5n1h2txyewy" "BioEnrollment"
"Microsoft.XboxGameCallableUI_cw5n1h2txyewy" "ContactSupport"
"Microsoft.XboxIdentityProvider_cw5n1h2txyewy" "Cortana"
"WindowsFeedback_cw5n1h2txyewy" "Feedback"
"Flash"
"OneDrive"
"Xbox"
) )
foreach ($app in $apps) { foreach ($needle in $needles) {
mv "$env:WinDir\SystemApps\$app" "$env:WinDir\SystemApps\_$app" $pkgs = (ls "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" |
where Name -Like "*$needle*")
foreach ($pkg in $pkgs) {
$pkgname = $pkg.Name.split('\')[-1]
Takeown-Registry($pkg.Name)
Takeown-Registry($pkg.Name + "\Owners")
Set-ItemProperty -Path ("HKLM:" + $pkg.Name.Substring(18)) -Name Visibility -Value 1
New-ItemProperty -Path ("HKLM:" + $pkg.Name.Substring(18)) -Name DefVis -PropertyType DWord -Value 2
Remove-Item -Path ("HKLM:" + $pkg.Name.Substring(18) + "\Owners")
dism.exe /Online /Remove-Package /PackageName:$pkgname /NoRestart
}
} }

Loading…
Cancel
Save