虚假功能 "Advertised" 状态导致卸载错误 1316

Spurious feature "Advertised" state results in uninstall error 1316

症状

用户 有时 在通过 add/remove 程序(或 "Apps & Features" 设置应用程序)卸载期间收到以下错误消息之一:

实际上这两个是完全相同的错误,第一个消息仅在安装了 KB2918614(又名 "Secure Repair" 补丁)且产品未列入白名单时出现。只是在这种情况下,错误代码被误解为一般的 system error instead of the actual MSI error。否则,KB2918614 无关紧要。

似乎不​​太常见。由于消息框包含一个 "Ignore" 按钮,它允许卸载继续进行,用户可能不太愿意报告此错误。

日志文件

通过msiexec -x {ProductCode} -l*vx LogFile.txt获得了卸载日志文件。搜索 "value 3" 会得到错误位置附近的部分:

MSI (s) (B0:9C) [15:18:10:427]: Executing op: FeatureUnpublish(Feature=ProductFeature,,Absent=2,Component=iJm4+0tc4@uTvD')YKUXZ{NA8`o569(2MdBLg[rJ)
MSI (s) (B0:9C) [15:18:10:428]: Note: 1: 1402 2: UNKNOWN\Installer\Features\AFCEC7274CC7C0441A85705C47554DD5 3: 2 
MSI (s) (B0:9C) [15:18:10:428]: Executing op: ActionStart(Name=InstallFiles,Description=Copying new files,Template=File: [1],  Directory: [9],  Size: [6])
MSI (s) (B0:9C) [15:18:10:428]: Executing op: ProgressTotal(Total=5,Type=0,ByteEquivalent=1)
MSI (s) (B0:9C) [15:18:10:428]: Executing op: SetTargetFolder(Folder=C:\Program Files\zett42\SpuriousFeatureAdvTest1\)
MSI (s) (B0:9C) [15:18:10:428]: Executing op: SetSourceFolder(Folder=1\zett42\xipmcfby\|zett42\SpuriousFeatureAdvTest1\)
MSI (s) (B0:9C) [15:18:10:428]: Executing op: ChangeMedia(,MediaPrompt=Please insert the disk: ,MediaCabinet=1\cab1.cab,BytesPerTick=65536,CopierType=1,,,SignatureRequired=0,,,IsFirstPhysicalMedia=1)
MSI (s) (B0:9C) [15:18:10:428]: Executing op: RegisterSharedComponentProvider(,,File=File2.txt,Component={3F28EEDB-866D-4201-8173-12532C657B6C},,ProductCode={727CECFA-7CC4-440C-A158-07C57455D45D},ProductVersion=1.0.0,PatchSize=0,PatchAttributes=0,PatchSequence=0,SharedComponent=0,IsFullFile=0)
MSI (s) (B0:9C) [15:18:10:428]: Executing op: FileCopy(SourceName=File2.txt,SourceCabKey=File2.txt,DestName=File2.txt,Attributes=512,FileSize=5,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=1397189395,HashPart2=108432067,HashPart3=-1009892414,HashPart4=374579663,,)
MSI (s) (B0:9C) [15:18:10:428]: File: C:\Program Files\zett42\SpuriousFeatureAdvTest1\File2.txt;    To be installed;    Won't patch;    No existing file
MSI (s) (B0:9C) [15:18:10:428]: Resolving source.
MSI (s) (B0:9C) [15:18:10:428]: Using cached product context: machine assigned for product: AFCEC7274CC7C0441A85705C47554DD5
MSI (s) (B0:9C) [15:18:10:428]: Using cached product context: machine assigned for product: AFCEC7274CC7C0441A85705C47554DD5
MSI (s) (B0:9C) [15:18:10:429]: Resolving source to launched-from source.
MSI (s) (B0:9C) [15:18:10:429]: Setting launched-from source as last-used.
MSI (s) (B0:9C) [15:18:10:429]: PROPERTY CHANGE: Adding SourceDir property. Its value is 'C:\WINDOWS\Installer\'.
MSI (s) (B0:9C) [15:18:10:429]: PROPERTY CHANGE: Adding SOURCEDIR property. Its value is 'C:\WINDOWS\Installer\'.
MSI (s) (B0:9C) [15:18:10:429]: PROPERTY CHANGE: Adding SourcedirProduct property. Its value is '{727CECFA-7CC4-440C-A158-07C57455D45D}'.
MSI (s) (B0:9C) [15:18:10:429]: SOURCEDIR ==> C:\WINDOWS\Installer\
MSI (s) (B0:9C) [15:18:10:429]: SOURCEDIR product ==> {727CECFA-7CC4-440C-A158-07C57455D45D}
MSI (s) (B0:9C) [15:18:10:429]: Using cached product context: machine assigned for product: AFCEC7274CC7C0441A85705C47554DD5
MSI (s) (B0:9C) [15:18:10:429]: Determining source type
MSI (s) (B0:9C) [15:18:10:429]: Note: 1: 2203 2: C:\WINDOWS\Installer\SpuriousFeatureAdvTest1.msi 3: -2147287038 
MSI (s) (B0:9C) [15:18:10:429]: Note: 1: 1316 2: C:\WINDOWS\Installer\SpuriousFeatureAdvTest1.msi 
MSI (s) (B0:9C) [15:18:10:429]: SECREPAIR: Error determining package source type
MSI (s) (B0:9C) [15:18:10:429]: SECUREREPAIR: SecureRepair Failed. Error code: 524FD15800
MSI (s) (B0:9C) [15:18:11:146]: Note: 1: 2205 2:  3: Error 
MSI (s) (B0:9C) [15:18:11:146]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709 
MSI (s) (B0:9C) [15:18:11:146]: Product: zett42 SpuriousFeatureAdvTest1 -- Error 1316. Das angegebene Konto ist bereits vorhanden.


MSI (c) (C4:38) [15:18:10:436]: Font created.  Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg

Error 1316. Das angegebene Konto ist bereits vorhanden.

(最后一行德语是 "The specified account already exists."。)

从日志中可以看出,卸载尝试实际上复制文件"File2.txt"到硬盘(寻找FileCopy条目).这似乎没有意义,当然当源不可用时它会失败。

同样有趣的是在日志中进一步显示的功能和组件状态:

MSI (s) (B0:9C) [15:18:10:387]: Feature: ProductFeature; Installed: Advertise;   Request: Absent;   Action: Absent
MSI (s) (B0:9C) [15:18:10:387]: Component: File1; Installed: Absent;   Request: Null;   Action: Null;   Client State: Unknown
MSI (s) (B0:9C) [15:18:10:387]: Component: File2; Installed: Local;   Request: Null;   Action: Local;   Client State: Absent

请注意,功能 "ProductFeature" 具有“已安装:广告”状态,尽管该功能是在本地安装的。组件 "File2" 的“Action: Local”与我们在日志中看到的内容相匹配,即 Windows 安装程序需要文件 installed 本地卸载!同样,这对我来说没有任何意义。

注册表缺陷

我发现在有问题的机器上,无法卸载的产品的随机组件注册表项丢失了:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\<ComponentKey>

手动添加缺少的注册表项(包括全新安装状态下的所有值)后,可以成功卸载产品。

事实证明,当缺少任何组件注册表项时,Windows 安装程序确定包含这些组件的功能的状态为 "advertised"。这仍然不足以导致卸载时出现错误 1316。事实上,只有当组件文件 物理上 在磁盘上丢失时,Windows 安装程序才会触发本地复制尝试。

最小示例和重现步骤

我还没有能够重现问题 "naturally",我。 e.与在客户机器上发生的方式相同。只有手动删除上述组件注册表项之一,我才能人为地重现问题。

  1. 构建一个安装两个文件的最小 WiX 安装程序,"File1.txt" 和 "File2.txt":
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define ProductName = "SpuriousFeatureAdvTest1"?>
  <?define Manufacturer = "zett42"?> 
  <?if $(var.Platform) = x64 ?>
    <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
  <?else ?>
    <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
  <?endif ?>

  <Product Id="*" Name="$(var.Manufacturer) $(var.ProductName)" Language="1033" Version="1.0.0.0" Manufacturer="$(var.Manufacturer)" UpgradeCode="{65CEA630-EFC0-4199-86EE-88867AABEDEF}">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="$(var.ProductName)" Level="1" AllowAdvertise="no" >
        <ComponentGroupRef Id="ProductComponents" />
    </Feature>

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="$(var.PlatformProgramFilesFolder)">
        <Directory Id="MANUFACTURERFOLDER" Name="$(var.Manufacturer)">
          <Directory Id="INSTALLFOLDER" Name="$(var.ProductName)" />
        </Directory>
      </Directory>
    </Directory>

    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="File1" Guid="{19819F06-DD45-4B48-BD00-810DEF7C0297}">
        <File Source="File1.txt"/>
      </Component>
      <Component Id="File2" Guid="{3F28EEDB-866D-4201-8173-12532C657B6C}">
        <File Source="File2.txt"/>
      </Component>
    </ComponentGroup>  
  </Product>
</Wix>
  1. 安装 MSI 文件。

  2. 删除属于组件 "File1" 的以下注册表项:

    HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\ComponentsF9189154DD84B4DB0018D0FEC72079
    
  3. 删除属于同一功能的任何 其他 组件的密钥文件,在本例中为 "File2":

    c:\Program Files\zett42\SpuriousFeatureAdvTest1\File2.txt
    
  4. 尝试通过 "Add/Remove Programs" 或 "Apps & Features" 卸载产品。

  5. 卸载失败并显示 "Error 1316" 消息。

尝试过的解决方案/解决方法

寻求支持:微软Program Install and Uninstall troubleshooter成功删除了有问题的产品。

我已尝试禁用该功能的广告 (<Feature AllowAdvertise="no"/>),但它没有任何改变。

问题

问题的可能原因是什么以及如何实际解决?

搜索错误信息表明问题很普遍。在some cases the error is caused by changing the file name of the MSI during a minor upgrade. This is definitely not the case here, because we don't do minor upgrades and the MSI files of the problematic setups were not renamed. As explained above it is very clear that there is a registry defect. A possibly similar case is described here中,但答案并没有说明什么,它只是指向MS故障排除工具。

我已经能够使用 注册表清理器 重现该问题。

重现步骤:

  1. 使用 Windows 安装程序安装程序。
  2. 从程序文件夹中删除一个或多个作为其组件关键文件的文件。
  3. 运行 注册表清理器。清洁工错误地 确定不再需要 Windows 安装程序组件注册表项,其密钥文件不存在。清理器删除注册表项。
  4. 从程序文件夹中删除更多作为其组件关键文件的文件。
  5. 尝试卸载该程序。它因错误 1316 而失败。

即使没有第 4 步,此卸载也会中断,因为包含已删除组件的具有相同功能的组件所安装的任何其他资源都不会被卸载。删除一个组件注册表项,整个功能将不再卸载!

随着第4步,问题变成了问题,因为整个卸载将回滚。当卸载作为需要先删除旧版本的主要升级的一部分运行时,它也可能变成安装问题。

虽然这些步骤看起来有些人为,但用户从程序安装文件夹中手动删除文件的可能性肯定不大。当程序安装在可移动磁盘上并且清理器在磁盘被移除后运行时,也可能会意外发生这种情况。可以考虑其他原因。

解法:

  • 不要使用注册表清理器。虽然有些可能确实有效,但它们总是存在破坏某些东西的风险。
  • 如果在卸载任何程序期间发生错误 1316 或 1406(也可能在主要升级期间,当旧版本被删除时),请在 "uninstall" 模式下使用 Microsoft Program Install and Uninstall troubleshooter。在某些情况下,您也可以通过重新运行用于安装程序的原始安装程序包来获得成功。