我使用了Windows 10:删除除指定应用程序之外的所有默认应用程序。
Get-AppxPackage -AllUsers | where-object {$_.name –notlike "*store*","*windowscalculator*","*people*"} | Remove-AppxPackage
出现错误部署失败,HRESULT:0x80073CFA。
Remove-AppxPackage : Deployment failed with HRESULT: 0x80073CFA, Removal failed. Please contact your software vendor. (Exception from HRESULT: 0x80073CFA)
error 0x80070032: AppX Deployment Remove operation on package 1527c705-839a-4832-9118-54d4Bd6a0c89_10.0.17134.1_neutral_neutral_cw5n1h2txyewy from:
C:\Windows\SystemApps\Microsoft.Windows.FilePicker_cw5n1h2txyewy failed. This app is part of Windows and cannot be uninstalled on a per-user basis. An administrator can attempt to remove the
app from the computer using Turn Windows Features on or off. However, it may not be possible to uninstall the app.
NOTE: For additional information, look for [ActivityId] 8c1923d8-2299-0001-fb83-198c9922d401 in the Event Log or use the command line Get-AppxLog -ActivityID
8c1923d8-2299-0001-fb83-198c9922d401
At line:1 char:106
+ ... like "*store*","*windowscalculator*","*people*"} | Remove-AppxPackage
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (1527c705-839a-4...l_cw5n1h2txyewy:String) [Remove-AppxPackage], IOException
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand
Remove-AppxPackage : Deployment failed with HRESULT: 0x80073CFA, Removal failed. Please contact your software vendor. (Exception from HRESULT: 0x80073CFA)
error 0x80070032: AppX Deployment Remove operation on package c5e2524a-ea46-4f67-841f-6a9465d9d515_10.0.17134.1_neutral_neutral_cw5n1h2txyewy from:
C:\Windows\SystemApps\Microsoft.Windows.FileExplorer_cw5n1h2txyewy failed. This app is part of Windows and cannot be uninstalled on a per-user basis. An administrator can attempt to remove
the app from the computer using Turn Windows Features on or off. However, it may not be possible to uninstall the app.
NOTE: For additional information, look for [ActivityId] 8c1923d8-2299-0000-8397-198c9922d401 in the Event Log or use the command line Get-AppxLog -ActivityID
8c1923d8-2299-0000-8397-198c9922d401
At line:1 char:106
+ ... like "*store*","*windowscalculator*","*people*"} | Remove-AppxPackage
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (c5e2524a-ea46-4...l_cw5n1h2txyewy:String) [Remove-AppxPackage], IOException
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand
Remove-AppxPackage : Deployment failed with HRESULT: 0x80073CFA, Removal failed. Please contact your software vendor. (Exception from HRESULT: 0x80073CFA)
error 0x80070032: AppX Deployment Remove operation on package E2A4F912-2574-4A75-9BB0-0D023378592B_10.0.17134.1_neutral_neutral_cw5n1h2txyewy from:
C:\Windows\SystemApps\Microsoft.Windows.AppResolverUX_cw5n1h2txyewy failed. This app is part of Windows and cannot be uninstalled on a per-user basis. An administrator can attempt to remove
the app from the computer using Turn Windows Features on or off. However, it may not be possible to uninstall the app.
NOTE: For additional information, look for [ActivityId] 8c1923d8-2299-0000-8c97-198c9922d401 in the Event Log or use the command line Get-AppxLog -ActivityID
8c1923d8-2299-0000-8c97-198c9922d401
At line:1 char:106
+ ... like "*store*","*windowscalculator*","*people*"} | Remove-AppxPackage
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (E2A4F912-2574-4...l_cw5n1h2txyewy:String) [Remove-AppxPackage], IOException
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand
找到解决方案这里
我的问题是,如果 MS 不想让我删除,那我也不想删除。但是,如果没有人反对,那我就想删除。因为,谁知道会有多少东西被破坏。
因此,我不想更改数据库或使用任何黑客手段。我想要一个脚本(希望是一行代码),它可以安全地删除尽可能多的臃肿软件(游戏、3D 对象……草图、XBox 等)。
如果删除时出现错误,不用担心!跳过并转到下一个应用程序并尝试将其删除。
答案1
请记住,总是有更优雅的方式来做事,但这只是一种选择。
您可以收集所有应用程序,然后循环将它们与您的应用程序白名单进行比较。
就像是:
"Uninstalling BlackListed apps"
$apps = @(
# Whitelist Windows 10 apps
"Microsoft.BingWeather"
"Microsoft.MicrosoftOfficeHub"
"Microsoft.Office.OneNote"
"Microsoft.SkypeApp"
"Microsoft.WindowsAlarms"
"Microsoft.WindowsCalculator"
"Microsoft.WindowsCamera"
"microsoft.windowscommunicationsapps"
"Microsoft.WindowsMaps"
"Microsoft.GetHelp"
"Microsoft.Messaging"
)
$RemoveAppPkgs = (Get-AppxPackage -AllUsers).Name
'TotalApps: ' + $RemoveAppPkgs.Count
'TotalWhiteListedApps: ' + $apps.Count
'TotalBlackListeedApps: ' + ($RemoveAppPkgs.Count - $apps.Count)
ForEach($TargetApp in $RemoveAppPkgs)
{
If($apps -notcontains $TargetApp)
{
Write-Output "Trying to remove $TargetApp"
}
}
输出:
Uninstalling BlackListed apps
TotalApps: 141
TotalWhiteListedApps: 11
TotalBlackListeedApps: 130
Trying to remove Windows.PrintDialog
Trying to remove Microsoft.NET.Native.Framework.1.0
Trying to remove Microsoft.NET.Native.Framework.1.0
Trying to remove Microsoft.NET.Native.Framework.1.1
Trying to remove Microsoft.NET.Native.Framework.1.1
Trying to remove Microsoft.NET.Native.Framework.1.6
Trying to remove Microsoft.NET.Native.Framework.1.6
Trying to remove Microsoft.NET.Native.Runtime.1.0
Trying to remove Microsoft.NET.Native.Runtime.1.0
Trying to remove Microsoft.NET.Native.Runtime.1.1
Trying to remove Microsoft.NET.Native.Runtime.1.1
Trying to remove Microsoft.NET.Native.Runtime.1.6
Trying to remove Microsoft.NET.Native.Runtime.1.6
Trying to remove Microsoft.VCLibs.120.00
Trying to remove Microsoft.VCLibs.120.00
...
正如您引用的指针所指出的,有些软件包您无法卸载:
# apps which cannot be removed using Remove-AppxPackage
#"Microsoft.BioEnrollment"
#"Microsoft.MicrosoftEdge"
#"Microsoft.Windows.Cortana"
#"Microsoft.WindowsFeedback"
#"Microsoft.XboxGameCallableUI"
#"Microsoft.XboxIdentityProvider"
#"Windows.ContactSupport"
如果其他人也遇到这个问题,你只需要捕获并跳过它们(使用 if/then 或 try/catch 块)。
* 根据 OP 请求更新 * 只需从您的帖子链接添加回代码即可完成删除。
ForEach($TargetApp in $RemoveAppPkgs)
{
If($apps -notcontains $TargetApp)
{
"Trying to remove $TargetApp"
Get-AppxPackage -Name $TargetApp -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue
Get-AppXProvisionedPackage -Online |
Where-Object DisplayName -EQ $TargetApp |
Remove-AppxProvisionedPackage -Online
}
}
或者,将您无法删除的应用程序添加到白名单中,这样您就不会遇到任何错误。
但是,无论何时,如果你正在做类似这样的破坏性操作,你都应该进行错误处理。我还建议你在真正执行此操作之前使用 -whatif 开关作为预防措施,删除内容。只是为了确保你真的得到了你期望的结果。
至于 try / catch 示例。如果您在 PowerShell_ISE 中,只需按 CRTL+J 即可调出代码片段列表并选择要使用的 try/catch 模板。