WiX卸载快捷方式需要HKCU下的密钥吗?

时间:2014-06-19 19:26:37

标签: xml compilation wix registry uninstall

所以我正在开发以下wix设置项目。我正在尝试向开始菜单添加卸载快捷方式,但在tutorial之后无效。所以,我尝试添加一些参数,现在我遇到了这个错误。虽然,我对它的含义感到困惑。

修改

我尝试将代码修改为:

<RegistryValue Root="HKCU" Key="Software\Microsoft\Viewer" Name="installed" Type="integer" Value="1" KeyPath="yes" />
<Shortcut Id="startmenuUninstall" Directory="ProgramMenuDir" Name="Viewer" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" />
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>

但现在它抱怨我定义了多个KeyPath。

WiX代码:

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
  <Product Name='Viewer 1.0' Id='9CC32BA4-F127-475D-9F65-549F5184ADAC' UpgradeCode='32F23DEA-B996-415D-9A12-CB9039D6A987'
    Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Direct'>
    <Package Id='*' Keywords='Installer' Description="Viewer Installer"
      Comments='Installer is a registered trademark.' Manufacturer='Direct'
      InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

    <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
    <Property Id='DiskPrompt' Value="1.0 Installation [1]" />
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='Direct' Name='DMD'>
          <Directory Id='INSTALLDIR' Name='Viewer'>

            <Component Id='MainExecutable' Guid='f3cdca42-0954-48c0-85aa-82e4bde65f14'>
                <Shortcut Id="startmenuViewer" Directory="ProgramMenuDir" Name="Viewer" WorkingDirectory='INSTALLDIR' Icon="Viewer.exe" IconIndex="0" Advertise="yes" />
                <Shortcut Id="desktopViewer" Directory="DesktopFolder" Name="Viewer" WorkingDirectory='INSTALLDIR' Icon="Viewer.exe" IconIndex="0" Advertise="yes" />
        <Shortcut Id="UninstallProduct" Directory="ProgramMenuDir" Name="Uninstall Viewer" Target="[SystemFolder]msiexec.exe" Icon="Viewer.exe" Arguments="/x [ProductCode]" Description="Uninstalls Viewer"/>

              <File Id='EXE' Name='Viewer.exe' DiskId='1' Source='Viewer.exe' KeyPath='yes'>
              </File>
                <ProgId Id="DMDCCDAV" Description="Viewer">
                    <Extension Id="xml" >
                        <Verb Id="open" Argument="&quot;%1&quot;" TargetFile="EXE" />
                    </Extension>
                </ProgId>
            </Component>

          </Directory>
        </Directory>
      </Directory>

      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ProgramMenuDir" Name="Viewer">
          <Component Id="ProgramMenuDir" Guid="*">
            <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
            <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
          </Component>
        </Directory>
      </Directory>

      <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>

    <Feature Id='Complete' Title='Viewer Installation' Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'>
    <Feature Id='MainProgram' Title='Viewer Program' Description='The main executable.' Level='1'>
      <ComponentRef Id='MainExecutable' />
      <ComponentRef Id='ProgramMenuDir' />
    </Feature>
    </Feature>

    <UIRef Id="WixUI_InstallDir" />
    <UIRef Id="WixUI_ErrorProgressText" />

    <Icon Id="Viewer.exe" SourceFile="Viewer.exe" />

  </Product>
</Wix>
编译时

错误:

C:\Users\kylec\Desktop\SampleFirst\SampleFirst.wxs(18) : error LGHT0204 : ICE43:
 Component MainExecutable has non-advertised shortcuts. It should use a registry
 key under HKCU as its KeyPath, not a file.
C:\Users\kylec\Desktop\SampleFirst\SampleFirst.wxs(18) : error LGHT0204 : ICE57:
 Component 'MainExecutable' has both per-user and per-machine data with a per-ma
chine KeyPath.

1 个答案:

答案 0 :(得分:0)

好的,我终于想通了,希望这也可以帮助其他人。我的问题是,我的卸载是在同一个组件。当我拔出卸载快捷方式并将其放在自己的组件中时,一切都很好。