无法通过 PowerShell 卸载通用应用程序

Rya*_*kna 12 powershell windows-store-app windows-10

当我遇到障碍时,我正在从新的 Windows 10 安装中卸载所有通用应用程序。

这不是我第一次这样做,而且总是很顺利。但是,这一次,每当我用 PowerShell

Get-AppxPackage -allusers | Remove-AppxPackage

或更具体的东西编写时,

Get-AppxPackage -allusers *windowscalculator* | Remove-AppxPackage

我都会收到以下消息:

Remove-AppxPackage:部署失败,HRESULT:0x80073CFA,删除失败。请联系您的软件供应商。(来自 HRESULT 的异常:0x80073CFA)错误 0x80070032:AppX 部署从 Microsoft.WindowsCalculator_10.1605.1582.0_x64__8wekyb3d8bbwe 包中删除操作:C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1628d8bbwe 失败。

此应用程序是 Windows 的一部分,无法按用户卸载。管理员可以尝试使用打开或关闭 Windows 功能从计算机中删除该应用程序。但是,可能无法卸载该应用程序。

注意:有关其他信息,请在事件日志中查找 [ActivityId] 75c5fc31-fb20-0001-77fd-c57520fbd101 或使用命令行 Get-AppxLog -ActivityID 75c5fc31-fb20-0001-77fd-c575010f

在行:1 字符:49

+ Get-appxpackage -allusers *windowscalculator* | Remove-AppxPackage + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (Microsoft.Windo...__8wekyb3d8bbwe:String) [Remove-AppxPackage], IOException + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand


对于我尝试卸载的每个应用程序,我都会收到此消息,包括那些我知道可以完全卸载的应用程序,例如计算器或图像查看器,这在以前从未发生过。
Powershell 正在运行,其他一切正常,看起来很正常。

除了重新安装 Windows 之外,我还能做些什么吗?

har*_*ymc 7

清洁除尘系统的应用程序(旁路错误0x80073CFA) 包含此PowerShell脚本:

function Enable-Privilege {  
  param($Privilege)
  $Definition = @'
using System;  
using System.Runtime.InteropServices;  
public class AdjPriv {  
  [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
  internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
    ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr rele);
  [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
  internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
  [DllImport("advapi32.dll", SetLastError = true)]
  internal static extern bool LookupPrivilegeValue(string host, string name,
    ref long pluid);
  [StructLayout(LayoutKind.Sequential, Pack = 1)]
  internal struct TokPriv1Luid {
    public int Count;
    public long Luid;
    public int Attr;
  }
  internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
  internal const int TOKEN_QUERY = 0x00000008;
  internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
  public static bool EnablePrivilege(long processHandle, string privilege) {
    bool retVal;
    TokPriv1Luid tp;
    IntPtr hproc = new IntPtr(processHandle);
    IntPtr htok = IntPtr.Zero;
    retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
      ref htok);
    tp.Count = 1;
    tp.Luid = 0;
    tp.Attr = SE_PRIVILEGE_ENABLED;
    retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
    retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero,
      IntPtr.Zero);
    return retVal;
  }
}
'@  
  $ProcessHandle = (Get-Process -id $pid).Handle
  $type = Add-Type $definition -PassThru
  $type[0]::EnablePrivilege($processHandle, $Privilege)
}

function Take-Over($path) {  
  $owner = [Security.Principal.NTAccount]'Administrators'

  $key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($path, 'ReadWriteSubTree', 'TakeOwnership')
  $acl = $key.GetAccessControl()
  $acl.SetOwner($owner)
  $key.SetAccessControl($acl)

  $acl = $key.getaccesscontrol()
  $rule = New-Object System.Security.AccessControl.RegistryAccessRule "Administrators", "FullControl", "ContainerInherit", "None", "Allow"
  $acl.SetAccessRule($rule)
  $key.SetAccessControl($acl)
}

do {} until (Enable-Privilege SeTakeOwnershipPrivilege)

function Remove-Package($name) {  
  $key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\$name"
  Take-Over $key
  Remove-Item -Path HKLM:"$key\Owners" -Force -Recurse
  & C:\Windows\System32\PkgMgr.exe /up:$name /norestart /quiet
}

#Remove Feedback
$packageBase = "Microsoft-WindowsFeedback"
$packageNames = (dir ("HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\" + $packageBase + "*")).name

forEach ($package in $packageNames)
{   
    Remove-Package $package.substring($package.indexOf($packageBase))
}
Run Code Online (Sandbox Code Playgroud)

在使用这个脚本时,作者说:

您可以将 $packageBase 更改为不同的包名称。

我自己没有尝试过这个脚本。

编辑:此脚本可能不再起作用,或者可能需要调整。


mag*_*981 6

从 Windows 10 周年更新开始,MicrosoftIsInbox在 SQLite 数据库中C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd为收件箱应用添加了一个新条目。并尝试删除标记为IsInbox失败的应用程序应用程序0x80073CFA

但是有一个丑陋的解决方法,它是在 2017 年 4 月发现的

您需要下载并安装ProcessHackerDB Browser for SQLite工具。

  • 以管理员身份运行 ProcessHacker 2,选择 a C:\Windows\System32\svchost.exe,右键单击并选择Misc->Run as this user

在此处输入图片说明

现在选择这里C:\Program Files\DB Browser for SQLite\DB Browser for SQLite.exe并启动它。在 SQLite 浏览器中,单击Open database

在此处输入图片说明

并打开文件C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd(将打开对话框中的文件类型更改为所有文件以查看它)。

现在,单击Browse Data选项卡,并将表更改为Package

在此处输入图片说明

现在选择要删除的应用程序并将列的 1 更改IsInbox0并保存更改。

在此处输入图片说明

对要删除的所有应用程序重复此操作,现在 PowerShell 命令应该可以工作了。

但作者写道,如果删除收件箱应用程序,微软会阻止升级到更新的 Windows 版本。所以请记住这一点。