Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall an UWP app programmatically

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?

like image 387
Louka Avatar asked Dec 10 '18 14:12

Louka


People also ask

How do I remove UWP from Start Menu?

Is there a way to remove the app from the Start menu? Yes: In your manifest, go to the VisualElements element and add the attribute AppListEntry="none" . This removes the app from the Start menu, as well as from Search.

What is the replacement for UWP?

As you already know, WinUI is Microsoft's follow-up to UWP. As the successor to the UWP platform, Microsoft has invested heavily in the WinUI platform.


1 Answers

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"
    }
}
like image 75
Danfossi Avatar answered Oct 18 '22 20:10

Danfossi