简体   繁体   English

如何以编程方式卸载UWP应用程序

[英]How to uninstall an UWP app programmatically

I've been trying to programmatically uninstall a Windows Store App (iTunes).I used below commands : 我一直在尝试以编程方式卸载Windows应用商店应用(iTunes)。我使用以下命令:

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. 但是当我在执行这些命令后启动iTunes安装(桌面版,而不是存储版)时,它会抱怨仍然安装了商店版本。

If I go to the "C:\\Program Files\\WindowsApps\\AppleInc.iTunes_12075.9.34012.0_x64__nzyj5cx40ttqa" there are still files in there. 如果我转到“C:\\ Program Files \\ WindowsApps \\ AppleInc.iTunes_12075.9.34012.0_x64__nzyj5cx40ttqa”,那里仍有文件。

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. 但是,如果我通过添加/删除而不是命令行删除iTunes商店版本,它工作正常,然后我可以安装iTunes标准。

One important point is that for some users, the command just work fine and I can install iTunes. 重要的一点是,对于某些用户来说,命令运行正常,我可以安装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? 在上述命令之后需要执行以完全卸载此Windows应用商店应用程序的其他一些命令(而不是Remove-AppxPackage)?

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"
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM