Skip to content

Commit

Permalink
win: prevent updates from reinstalling apps $260
Browse files Browse the repository at this point in the history
This commit addresses the issue of unwanted applications being
reinstalled during a Windows update. By adding a specific registry
entry, this commit ensures that Windows apps, once removed, do not
return with subsequent updates.

This change ensures more control over the applications present on a
Windows system, particularly after an update, enhancing user experience
and systeam cleanliness.
  • Loading branch information
undergroundwires committed Oct 23, 2023
1 parent d6da406 commit e97b8a4
Showing 1 changed file with 55 additions and 39 deletions.
94 changes: 55 additions & 39 deletions src/application/collections/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9967,47 +9967,63 @@ functions:
- name: packageName
- name: publisherId
call:
function: RunPowerShell
parameters:
code: Get-AppxPackage '{{ $packageName }}' | Remove-AppxPackage
# Package Family Name is: `<name>_<publisherid>`, https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/package-identity-overview#publisher-id
revertCode: |-
$packageName='{{ $packageName }}'
$publisherId='{{ $publisherId }}'
Write-Host "Starting the installation process for `"$packageName`"..."
# Attempting installation using the manifest file
Write-Host "Checking if `"$packageName`" is installed on another user profile..."
$package = Get-AppxPackage -AllUsers $packageName
if (!$package) {
Write-Host "`"$packageName`" is not installed on any other user profiles."
} else {
Write-Host "Found package `"$($package.PackageFullName)`"."
$manifestPath = "$($package.InstallLocation)AppxManifest.xml"
if (Test-Path "$manifestPath") {
Write-Host "Manifest file located. Trying to install using the manifest..."
try {
Add-AppxPackage -DisableDevelopmentMode -Register "$manifestPath" -ErrorAction Stop
Write-Host "Successfully installed `"$packageName`" using its manifest file."
exit 0
} catch {
Write-Warning "Error installing from manifest: $($_.Exception.Message)"
}
-
function: RunPowerShell
parameters:
code: Get-AppxPackage '{{ $packageName }}' | Remove-AppxPackage
# Package Family Name is: `<name>_<publisherid>`, https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/package-identity-overview#publisher-id
revertCode: |-
$packageName='{{ $packageName }}'
$publisherId='{{ $publisherId }}'
Write-Host "Starting the installation process for `"$packageName`"..."
# Attempting installation using the manifest file
Write-Host "Checking if `"$packageName`" is installed on another user profile..."
$package = Get-AppxPackage -AllUsers $packageName
if (!$package) {
Write-Host "`"$packageName`" is not installed on any other user profiles."
} else {
Write-Host "Manifest file not found for `"$packageName`"."
Write-Host "Found package `"$($package.PackageFullName)`"."
$manifestPath = "$($package.InstallLocation)AppxManifest.xml"
if (Test-Path "$manifestPath") {
Write-Host "Manifest file located. Trying to install using the manifest..."
try {
Add-AppxPackage -DisableDevelopmentMode -Register "$manifestPath" -ErrorAction Stop
Write-Host "Successfully installed `"$packageName`" using its manifest file."
exit 0
} catch {
Write-Warning "Error installing from manifest: $($_.Exception.Message)"
}
} else {
Write-Host "Manifest file not found for `"$packageName`"."
}
}
}
# Attempting installation using the package family name
$packageFamilyName = "$($packageName)_$($publisherId)"
Write-Host "Trying to install `"$packageName`" using its package family name: `"$packageFamilyName`"..."
try {
Add-AppxPackage -RegisterByFamilyName -MainPackage $packageFamilyName -ErrorAction Stop
Write-Host "Successfully installed `"$packageName`" using its package family name."
exit 0
} catch {
Write-Warning "Error installing using package family name: $($_.Exception.Message)"
}
# If all methods fail
throw "Unable to install `"$packageName`". Please check the provided details and try again."
# Attempting installation using the package family name
$packageFamilyName = "$($packageName)_$($publisherId)"
Write-Host "Trying to install `"$packageName`" using its package family name: `"$packageFamilyName`"..."
try {
Add-AppxPackage -RegisterByFamilyName -MainPackage $packageFamilyName -ErrorAction Stop
Write-Host "Successfully installed `"$packageName`" using its package family name."
exit 0
} catch {
Write-Warning "Error installing using package family name: $($_.Exception.Message)"
}
# If all methods fail
throw "Unable to install `"$packageName`". Please check the provided details and try again."
-
function: RunInlineCode
# Prevent applications from being reinstalled during a Windows update.
# For more information:
# - https://learn.microsoft.com/en-us/windows/application-management/remove-provisioned-apps-during-update#create-registry-keys-for-deprovisioned-apps
# - Archived: https://archive.ph/04108, https://web.archive.org/web/20231023131048/https://learn.microsoft.com/en-us/windows/application-management/remove-provisioned-apps-during-update#create-registry-keys-for-deprovisioned-apps
# - https://learn.microsoft.com/en-us/mem/configmgr/osd/understand/in-place-upgrade-recommendations#remove-default-apps
# - Archived: https://archive.ph/I7Dwc, https://web.archive.org/web/20231023132613/https://learn.microsoft.com/en-us/mem/configmgr/osd/understand/in-place-upgrade-recommendations#remove-default-apps
parameters:
code: |-
:: Mark the application as deprovisioned to prevent it from reinstalling during Windows updates.
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\{{ $packageName }}_{{ $publisherId }}" /f
revertCode: |-
:: Remove the deprovisioned status to allow the application to reinstall during Windows updates.
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\{{ $packageName }}_{{ $publisherId }}"
-
name: UninstallSystemApp
parameters:
Expand Down

0 comments on commit e97b8a4

Please sign in to comment.