How to uninstall an UWP app programmatically
Asked Answered
D

1

9

I've been trying to programmatically uninstall a Windows Store App (iTunes).I used below commands :

Remove-AppxPackage -Package AppleInc.iTunes_12092.6.37131.0_x64__nzyj5cx40ttqa 

and as admin

Remove-AppxPackage -Package AppleInc.iTunes_12092.6.37131.0_x64__nzyj5cx40ttqa -AllUsers

The commands executes fine without errors and the apps disappear in start menu, and Add/Remove programs. But when I start the iTunes installation (desktop version, not store) after those commands execution, it complains that a store version is still installed.

If I go to the "C:\Program Files\WindowsApps\AppleInc.iTunes_12075.9.34012.0_x64__nzyj5cx40ttqa" there are still files in there.

However, if I remove the iTunes store version via the Add/Remove instead of command line, it works fine and then I can install iTunes standard.

One important point is that for some users, the command just work fine and I can install iTunes.

My question is, Am I missing something? Is there a cache that needs to be cleaned ? Some other commands (than Remove-AppxPackage) that need to be executed after above commands to fully uninstall this Windows Store app?

Demented answered 10/12, 2018 at 14:29 Comment(3)
I have tested second Command and it works well,after command invoked I could install itunes desktop version successfully.Johnajohnath
Indeed I forgot to precise that it was working for some users, but others have this problem. I couldn't find a standard scheme. Same OS version, same iTunes version.Demented
Have you check this document.Johnajohnath
A
1

Try something like this:

$AppList = "AppleInc.iTunes"
ForEach ($App in $AppList) {
    $PackageFullName = (Get-AppxPackage $App).PackageFullName
    $ProPackageFullName = (Get-AppxProvisionedPackage -online | where {$_.Displayname -eq $App}).PackageName
    write-host $PackageFullName
    Write-Host $ProPackageFullName
    if ($PackageFullName) {
        Write-Host "Removing Package: $App"
        remove-AppxPackage -package $PackageFullName
    }
    else{
        Write-Host "Unable to find package: $App"
    }
    if ($ProPackageFullName) {
        Write-Host "Removing Provisioned Package: $ProPackageFullName"
        Remove-AppxProvisionedPackage -online -packagename $ProPackageFullName
    }
    else {
        Write-Host "Unable to find provisioned package: $App"
    }
}
Abijah answered 28/2, 2019 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.