代码之家  ›  专栏  ›  技术社区  ›  marc_s MisterSmith

Wix3让我抓狂-尝试创建桌面快捷方式

  •  22
  • marc_s MisterSmith  · 技术社区  · 15 年前

    我有一个与Wix3一起安装的应用程序-到目前为止,大多数安装都可以正常工作,但是尝试使用桌面快捷方式工作似乎让我付出了代价…

    我已经安装了我的应用程序,并且在“开始”菜单文件夹上已经有了快捷方式-工作正常。But how do I get the desktop shortcut up and running?

    <Product Id="*" Name="....." UpgradeCode="MY-GUID">
      <Package Id="*" InstallerVersion="200" Compressed="yes" />
        <Media Id="1" Cabinet="foobar.cab" EmbedCab="yes" />
        <Property Id="ALLUSERS">1</Property>
    
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramMenuFolder">
            <Directory Id="ApplicationProgramsFolder" Name="FooBar"/>
          </Directory>
          <Directory Id="DesktopFolder"  SourceName="Desktop"/>
          <Directory Id="ProgramFilesFolder">
             <Directory Id="FoobarDir" Name="FOOBAR">
                <Directory Id="INSTALLLOCATION" Name="FooApp">
                  <Component Id="MainFiles" Guid=".....">
                    <File Id="FooMainApp" Source="FooMainApp.exe" />
                  </Component>
                </Directory>
             </Directory>
          </Directory>
        </Directory>
        ....
        <!-- this shortcut here works just fine ... -->
        <DirectoryRef Id="ApplicationProgramsFolder">
          <Component Id="AppShortcut" Guid="...">
             <Shortcut Id="ApplicationStartMenuShortcut"
                       Name="FooBarApp" Description="..."
                       Target="[INSTALLLOCATION]FooMainApp.exe"
                       WorkingDirectory="INSTALLLOCATION"/>
          </Component>
        </DirectoryRef>
        <!-- but this shortcut here never seems to work .. ... -->
        <DirectoryRef Id="DesktopFolder">
           <Component Id="DesktopShortcut" Guid="....." >
              <Shortcut Id="DesktopAppShortcut"
                        Advertise="no"
                        Name="FooBarApp"  Description="...."
                        Target="[INSTALLLOCATION]FooMainApp.exe"
                        WorkingDirectory="INSTALLLOCATION"/>
           </Component>
        </DirectoryRef>
    

    我一直犯的错误是:

    ICE18: 组件的键路径: “desktopshortcut”是目录: “桌面文件夹”。这个 目录/组件对必须是 列在CreateFolders表中。
    ICE38 组件桌面快捷方式 安装到用户配置文件。必须使用 香港中文大学的注册机码 关键路径,不是文件。
    ICE43: 成分 桌面快捷方式没有公布 捷径。它应该使用一个注册表 钥匙在香港中文大学作为其钥匙路径,而不是 文件。

    我不明白wix 3/windows安装程序到底想告诉我什么……有人吗??

    两个组件, AppShortcut DesktopShortcut ,实际上是“主要”功能的一部分-我没有看到任何问题。我不知道到底是什么地方出了问题……

    更新: 好的,所以我在桌面快捷方式中添加了一些注册表项内容

    <Component Id="DesktopShortcut" Guid="BF3587B4-F52E-411E-8814-CFCBF8201C0D">
        <RegistryKey Root="HKCU" Key="Software\Foo Inc\FooBarApp\Installed" 
                     Action="createAndRemoveOnUninstall">
           <RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes"/>
        </RegistryKey>
        <Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
                  Name="FooBar" WorkingDirectory="INSTALLLOCATION"
                  Icon="foobar.ico" 
                  Target="[INSTALLOCATION]FooMainApp.exe"/>
    </Component>
    

    现在,ICE消息不见了,但是当我尝试安装应用程序时,我收到错误1909-目标文件夹不存在,或者您没有权限对其进行写入(或类似的操作)。

    更新2: 上面提供的示例代码在Win XP上有效,但在Win Server 2003上却一直失败:—(还有什么想法吗??

    5 回复  |  直到 10 年前
        1
  •  18
  •   saschabeaumont    15 年前

    以下是我们的实时生产代码的一个工作示例…

    <Fragment>
        <Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
            <RegistryValue Id="RegShortcutDesktop" Root="HKCU" 
                    Key="SOFTWARE\ACME\settings" Name="DesktopSC" Value="1" 
                    Type="integer" KeyPath="yes" />
            <Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]MyApp.exe"
                    Directory="DesktopFolder" Name="My Application" 
                    Icon="$(var.product).ico" IconIndex="0"
                    WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
        </Component>
    </Fragment>
    
        2
  •  7
  •   noelicus    12 年前

    这是基于@saschabaumont的答案,但希望能为我们的wix初学者提供一些额外的有用提示(这对每个人来说都是一场噩梦吗???).

    首先,创建一个包含快捷方式详细信息本身的片段:

    <Fragment>
    <Component Id="DesktopShortcut" Directory="INSTALLFOLDER" Guid="*">
        <RegistryValue Id="RegShortcutDesktop" 
                Root="HKCU" 
                Key="Software\Company\ApplicationName"
                Name="DesktopSC"
                Value="1" 
                Type="integer"
                KeyPath="yes" />
    
        <Shortcut Id="desktopSC" 
                Target="[INSTALLFOLDER]ApplicationName.exe"
                WorkingDirectory="INSTALLFOLDER"
                Icon="icon.ico"
                Directory="DesktopFolder" 
                Name="ApplicationName" 
                Advertise="no"/>
    </Component>
    </Fragment>
    

    接下来,注意这个片段需要包括在 Product element ,像这样:

    <Feature Id="ProductFeature" Title="Your Application Title" Level="1">
        ...
        <ComponentRef Id="DesktopShortcut" />
    </Feature>
    

    这个 ProductFeature 可能包含其他片段,如文件和程序菜单快捷方式片段。

    此外, DesktopFolder 需要在 TARGETDIR directory element (很可能包含其他文件夹,例如 ProgramMenuFolder 如您所需),如下所示:

    <Directory Id="TARGETDIR" Name="SourceDir">
        ...
        <Directory Id="DesktopFolder" Name="Desktop"/>
    </Directory>
    
        3
  •  6
  •   Community Mohan Dere    8 年前

    每一个 ICE 消息基本上都在抱怨同一件事:安装快捷方式的组件应该有一个注册表项作为它的 keypath . 要修复此问题,请向组件中添加如下内容:

    <RegistryValue Root="HKCU" Key="Software\MyCompany\MyApplicationName" 
        Name="desktopShortcut" Type="integer" Value="1" KeyPath="yes"/>
    

    安装“开始”菜单快捷方式的组件也是如此。看看相关的 wix documentation sample about creating a shortcut .

        4
  •  2
  •   Mason Zhang    14 年前

    我的目的是创建一个Internet快捷链接并放到桌面上。以下是适用于我的代码:

    <?xml version="1.0" encoding="utf-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
        <Product Id="09F1B63D-FB03-43FD-A326-FD49F93D00C8" Name="TestProduct" Language="1033" Version="0.0.0.1" Manufacturer="WixEdit" UpgradeCode="6B2F9AB4-73A6-45CB-9EC4-590D1AAA6779">
            <Package Description="Test file in a Product" Comments="Simple test" InstallerVersion="200" Compressed="yes" />
            <Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
            <Directory Id="TARGETDIR" Name="SourceDir">
                <Directory Id="ProgramFilesFolder" Name="PFiles">
                    <Directory Name="AAAA" Id="AAABBB">
                        <Component Id="AAAA">
                            <File Id="AAAA.EXE" Name="AAAA.exe" Source="U:\web\bin\x86\Release\AAAA.exe" />
                        </Component>
                    </Directory>
                </Directory>
                <Directory Id="DesktopFolder">
                        <Component Id="StartMenuShortcuts" Guid="E8EDD7BC-9762-4C3D-8341-FAEC983D318A">
                            <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                            <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" />
                            <util:InternetShortcut Id="WebsiteShortcut" Name="AAAA Website" Target="http://www.AAAA.com" />
                        </Component>
                </Directory>
            </Directory>
            <Feature Id="DefaultFeature" Title="Main Feature" Level="1">
                <ComponentRef Id="StartMenuShortcuts" />
                <ComponentRef Id="AAAA" />
            </Feature>
            <UI />
        </Product>
    </Wix>
    

    注意:您需要将以下内容添加到 蜡烛 命令行: -外部WixUtilExtension

        5
  •  0
  •   Sean Hall    12 年前

    不确定这在2010年是否可用,但我在wix 3.7中是这样做的:

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="DesktopFolder" SourceName="Desktop" />
      <Directory Id="MergeRedirectFolder">
        <Component Id="MyExeComponent" Guid="{PUT-GUID-HERE}">
          <File Id="MyExeFile" Source="$(var.ExeSourcePath)" KeyPath="yes">
            <Shortcut
              Id="DesktopShortcut"
              Directory="DesktopFolder"
              Name="$(var.ShortcutName)"
              WorkingDirectory="MergeRedirectFolder" />
          </File>
        </Component>
      </Directory>
    </Directory>
    
    推荐文章