【问题标题】:How can I create a shortcut on the Users Desktop folder如何在用户桌面文件夹上创建快捷方式
【发布时间】:2015-03-25 12:39:22
【问题描述】:

根据 craigster 更新了完整的 Wix 项目

<?xml version="1.0" encoding="UTF-8"?>
<?define SourceDir = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug" ?>
<?define icon = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug\1Password.ico" ?>
<?define DesktopFolder = "H:\Desktop" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">  
    <Product Id="*" Name="APS" Language="1033" Version="1.3.0.0" Manufacturer="SS" UpgradeCode="890c447c-5a09-4abb-9b01-fadf5e64aad5">
      <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
        Description="APS 1.2"
        Comments="APS will assist you with changing your password with a single click!"
        Manufacturer="SS"
        InstallPrivileges="elevated"
        Platform="x86" />

      <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
      <MediaTemplate EmbedCab="yes" />

      <Feature Id="ProductFeature" Title="AutomatedIDSystemInstaller" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
      </Feature>
    </Product>

    <Fragment>
      <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
          <Directory Id="INSTALLFOLDER" Name="APS" />
        </Directory>
      </Directory>
    </Fragment>
    <Fragment>
      <DirectoryRef Id="TARGETDIR">
        <Directory Id="DesktopFolder" />
      </DirectoryRef>
      <Icon Id="Password.ico" SourceFile="$(var.SourceDir)\1Password.ico" />
      <Property Id="ARPPRODUCTICON" Value="Password.ico" />
    </Fragment>

  <!-- The casing of 'ANOTHERLOCATION' and 'WindowsVolume' is very important here.
     Replace 'MyNewDir' with the correct name of the folder you want on
     WindowsVolume.
-->
    <SetDirectory Id="DesktopFolder" Value="H:\Desktop" />


    <!--<Fragment>
    <Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
      <RegistryValue Id="RegShortcutDesktop" Root="HKCU"
              Key="SOFTWARE\APS\settings" Name="DesktopSC" Value="1"
              Type="integer" KeyPath="yes" />
      <Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]APS.exe"
              Directory="DesktopFolder" Name="APS"
              IconIndex="0"
              WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
    </Component>
  </Fragment>-->

    <Fragment>
      <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
        <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
        <!-- <Component Id="ProductComponent"> -->
        <!-- TODO: Insert files, registry keys, and other resources here. -->
        <!-- </Component> -->
        <!--<Component Id="ProductComponents">
        <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">
          <Shortcut Id="APSShortcut" 
                    Name="APS"
                    Advertise="yes" 
                    Description="1-Click to Change all your passwords!" 
                    WorkingDirectory="INSTALLFOLDER" 
                    ShortName="APS"                      
                    Directory="DesktopFolder"/>
        </File>
      </Component>-->


        <Component Guid="{27E3322C-C85D-4451-A06D-21B524878CA0}">

          <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">

            <Shortcut Id="APSShortcut"
                      Name="APS"
                      Advertise="yes"
                      Description="1-Click to Change all your passwords!"
                      WorkingDirectory="INSTALLFOLDER"
                      ShortName="APS"
                      Directory="DesktopFolder" Icon="Password.ico" IconIndex="0" />
          </File>
        </Component>
        <Component Id="HtmlAgilityPack.dll" Guid="{119C78DC-EFE5-4C84-9583-17F3DE341EFC}">
          <File Id="HtmlAgilityPack.dll" Source="$(var.SourceDir)\HtmlAgilityPack.dll" KeyPath="yes" />
        </Component>
        <Component Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Guid="{D6DBE101-004B-4383-A5F5-7BF16EB0C0FC}">
          <File Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Source="$(var.SourceDir)\Microsoft.VisualBasic.PowerPacks.Vs.dll" KeyPath="yes" />
        </Component>
        <Component Id="rtools_setup_x64.exe" Guid="{622D3FCF-E3A0-4A12-99B0-E9D7F879CB16}">
          <File Id="rtools_setup_x64.exe" Source="$(var.SourceDir)\rtools_setup_x64.exe" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.application" Guid="{DB61CF4D-E785-44FD-BB95-D19F7D1619FB}">
          <File Id="AutomatedIDSystem.application" Source="$(var.SourceDir)\APS.application" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.exe.config" Guid="{3E1CD5E7-1AF7-47AF-9FE3-30CEC56EF950}">
          <File Id="AutomatedIDSystem.exe.config" Source="$(var.SourceDir)\APS.exe.config" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.exe.manifest" Guid="{07689029-E9E0-47C0-87D7-5A94FC959EDF}">
          <File Id="AutomatedIDSystem.exe.manifest" Source="$(var.SourceDir)\APS.exe.manifest" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.pdb" Guid="{4D3FBB60-6F55-439E-A88B-ADE7AF7A7459}">
          <File Id="AutomatedIDSystem.pdb" Source="$(var.SourceDir)\APS.pdb" KeyPath="yes" />
        </Component>
        <!--<Component Id="AutomatedIDSystem.vshost.application" Guid="{684D3AC6-FC03-4E87-944B-2D897169CDDE}">
        <File Id="AutomatedIDSystem.vshost.application" Source="$(var.SourceDir)\APS.vshost.application" KeyPath="yes" />
      </Component>-->
        <Component Id="AutomatedIDSystem.vshost.exe" Guid="{478284E1-999D-481D-91B4-4F8F15B998A6}">
          <File Id="AutomatedIDSystem.vshost.exe" Source="$(var.SourceDir)\APS.vshost.exe" KeyPath="yes" />
        </Component>
        <!--<Component Id="AutomatedIDSystem.vshost.exe.config" Guid="{099D79F8-370D-40FE-A6C2-0B76B6397FC7}">
        <File Id="AutomatedIDSystem.vshost.exe.config" Source="$(var.SourceDir)\APS.vshost.exe.config" KeyPath="yes" />
      </Component>-->
        <!--<Component Id="AutomatedIDSystem.vshost.exe.manifest" Guid="{48F07333-9C5B-4894-961D-531C26874531}">
        <File Id="AutomatedIDSystem.vshost.exe.manifest" Source="$(var.SourceDir)\APS.vshost.exe.manifest" KeyPath="yes" />
      </Component>-->
        <Component Id="Password.ico" Guid="{99391003-D8EE-4E6A-98E2-393F2ECE09D8}">
          <File Id="Password.ico" Source="$(var.SourceDir)\1Password.ico" KeyPath="yes" />
        </Component>
        <Component Id="setup.bat" Guid="{0460C522-A02B-4C8B-A0EE-34F1AFF677D1}">
          <File Id="setup.bat" Source="$(var.SourceDir)\setup.bat" KeyPath="yes" />
        </Component>

        <Component Id="netframework" Guid="{6BFA9239-38C7-4040-9487-6A5D20315CA7}">
          <File Id="netframework" Source="$(var.SourceDir)\dotnetfx452_full_x86_x64.exe" KeyPath="yes" />
        </Component>

        <!--    <Component Id="DesktopShortcut" Directory="DesktopFolder"> -->
        <Component Id="ApplicationShortcutDesktop" Guid="902B784B-B1F0-4629-AAC9-D46845734248">
          <Shortcut Id="ApplicationDesktopShortcut" Name="AppName" Description="APS" Target="[INSTALLFOLDER]APS.exe" WorkingDirectory="INSTALLFOLDER" />
          <RemoveFolder Id="DesktopFolder" On="uninstall" />
          <RegistryValue Root="HKCU" Key="Software\APS" Name="installed" Type="integer" Value="1" KeyPath="yes" />
        </Component>
        <!--</Component>-->

      </ComponentGroup>
    </Fragment>
  </Wix>

按照 craigster 的指示,它正在为第 31 行提供警告

 <SetDirectpry Id="DesktopFolder" Value="H:\Desktop" />

第 41 行的警告说

Show Details    Severity    Code    Description Project File    Line
    Error       The Wix element contains an unexpected child element 'SetDirectory'.    Product.wxs 41
    Warning     The element 'Wix' in namespace 'http://schemas.microsoft.com/wix/2006/wi' has invalid child element 'SetDirectory' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. List of possible elements expected: 'Fragment' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. Product.wxs 41

请告诉我我需要对我的 WIX 做什么才能在 H:\Desktop 上创建快捷方式

我还需要删除什么,因为它是不必要的/多余的。

【问题讨论】:

  • 安装范围是每台机器,因此“用户”表示“所有用户”。
  • 您解决了吗?另一种解决方案是使用设置属性自定义操作来获取用户桌面的路径,然后在此处安装带有快捷方式的组件。但是,这不会清除卸载时所有潜在的每个用户快捷方式,并且您需要在新用户登录时为每个用户运行主动设置或自我修复以添加到所有用户配置文件中。

标签: c# wix wix3.5


【解决方案1】:

这个问题有点像

Wix toolset: create directory in root disk (system disk or c:\) and copy files inside

这是我的完整 wxs 文件

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="PosBeQBSyncSetup" Language="1033" Version="1.9.26"     Manufacturer="CompanyName" UpgradeCode="79d05903-6471-46e9-913c-    a7b080adc03f">
 <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"     />

<Media Id="1" Cabinet="cab1.cab" EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of MyApp is already installed." />
<Icon Id="icon.ico" SourceFile="..\MyApp\Resources\qbicon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Feature Id="ProductFeature" Title="MyApp" Level="1">
  <ComponentGroupRef Id="ProductComponents" />
</Feature>
<Feature Id="DesktopShortCut" Title="MyApp" Level="1">
  <ComponentGroupRef Id="DesktopShortcut" />
</Feature>
<Feature Id="AppProgramsShortCut" Title="MyApp" Level="1">
  <ComponentGroupRef Id="ProgramsShortcut" />
</Feature>

<UI />
</Product>
<Fragment>

<SetDirectory Id="DesktopFolder" Value="F:\Desktop" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="MyApp" />
  </Directory>
  <Directory Id="CommonAppDataFolder">
    <Directory Id="DataFolder" Name="MyApp" />
  </Directory>
  <Directory Id="DesktopFolder" Name="Desktop" />
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ApplicationProgramsFolder" Name="MyApp" />
  </Directory>
</Directory>

</Fragment>
<Fragment>
<ComponentGroup Id="DesktopShortcut" Directory="DesktopFolder">
  <Component Id="ApplicationShortcutDesktop" Guid="FF285292-BB8A-4012-96E4-70C126B2F030">
    <Shortcut Id="ApplicationDesktopShortcut" Name="MyApp" Description="MyApp" Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER"  />
    <RemoveFolder Id="DesktopFolder" On="uninstall" />
    <RegistryValue Root="HKCU" Key="Software\MyApp" Name="installed" Type="integer" Value="1" KeyPath="yes" />
  </Component>
</ComponentGroup>
<ComponentGroup Id="ProgramsShortcut" Directory="ApplicationProgramsFolder">
  <Component Id="ApplicationShortcut" Guid="664186E9-BD9D-4555-A1AA-571BA31AD990">
    <Shortcut Id="ApplicationStartMenuShortcut" Name="MyApp" Description="MyApp" Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER" />
    <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
    <RegistryValue Root="HKCU" Key="Software/MyApp" Name="installed" Type="integer" Value="1" KeyPath="yes" />
  </Component>
</ComponentGroup>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
  <Component Id="MyApp.exe">
    <!-- TODO: Insert files, registry keys, and other resources here. -->
    <File Source="..\MyApp\bin\Release\MyApp.exe" />
  </Component>
  </ComponentGroup>
  </Fragment>
  </Wix>

您还需要在这里将这三个部分添加到您的 wxs 文件中。 不要忘记功能部分

将此添加到功能部分

<Feature Id="DesktopShortCut" Title="AppName" Level="1">
  <ComponentGroupRef Id="DesktopShortcut" />
</Feature>

将此添加到您的目录部分

  <SetDirectory Id="DesktopFolder" Value="H:\Desktop" />
  <Directory Id="DesktopFolder" Name="Desktop" />

同时添加这个 CompenentGroup

  <ComponentGroup Id="DesktopShortcut" Directory="DesktopFolder">
  <Component Id="ApplicationShortcutDesktop" Guid="FF285292-BB8A-4012-96E4-70C126B2F030">
    <Shortcut Id="ApplicationDesktopShortcut" Name="AppName" Description="AppName" Target="[INSTALLFOLDER]AppName.exe" WorkingDirectory="INSTALLFOLDER" />
    <RemoveFolder Id="DesktopFolder" On="uninstall" />
    <RegistryValue Root="HKCU" Key="Software\AppName" Name="installed" Type="integer" Value="1" KeyPath="yes" />
  </Component>
</ComponentGroup>

你的文件应该是这样的

<?xml version="1.0" encoding="UTF-8"?>
<?define SourceDir = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug" ?>
<?define icon = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug\1Password.ico" ?>
<?define DesktopFolder = "H:\Desktop" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">  
<Product Id="*" Name="APS" Language="1033" Version="1.3.0.0" Manufacturer="SS" UpgradeCode="890c447c-5a09-4abb-9b01-fadf5e64aad5">
  <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
    Description="APS 1.2"
    Comments="APS will assist you with changing your password with a single click!"
    Manufacturer="SS"
    InstallPrivileges="elevated"
    Platform="x86" />

  <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
  <MediaTemplate EmbedCab="yes" />

  <Feature Id="ProductFeature" Title="AutomatedIDSystemInstaller" Level="1">
    <ComponentGroupRef Id="ProductComponents" />
  </Feature>
</Product>

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="APS" />
    </Directory>
  </Directory>
</Fragment>
<Fragment>
  <DirectoryRef Id="TARGETDIR">
    <Directory Id="DesktopFolder" />
  </DirectoryRef>
  <Icon Id="Password.ico" SourceFile="$(var.SourceDir)\1Password.ico" />
  <Property Id="ARPPRODUCTICON" Value="Password.ico" />
</Fragment>

<!--<Fragment>
<Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
  <RegistryValue Id="RegShortcutDesktop" Root="HKCU"
          Key="SOFTWARE\APS\settings" Name="DesktopSC" Value="1"
          Type="integer" KeyPath="yes" />
  <Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]APS.exe"
          Directory="DesktopFolder" Name="APS"
          IconIndex="0"
          WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
</Component>
</Fragment>-->

<Fragment>
  <SetDirectory Id="DesktopFolder" Value="H:\Desktop" />
  <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
    <!-- <Component Id="ProductComponent"> -->
    <!-- TODO: Insert files, registry keys, and other resources here. -->
    <!-- </Component> -->
    <!--<Component Id="ProductComponents">
    <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">
      <Shortcut Id="APSShortcut" 
                Name="APS"
                Advertise="yes" 
                Description="1-Click to Change all your passwords!" 
                WorkingDirectory="INSTALLFOLDER" 
                ShortName="APS"                      
                Directory="DesktopFolder"/>
    </File>
  </Component>-->


    <Component Guid="{27E3322C-C85D-4451-A06D-21B524878CA0}">

      <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">

        <Shortcut Id="APSShortcut"
                  Name="APS"
                  Advertise="yes"
                  Description="1-Click to Change all your passwords!"
                  WorkingDirectory="INSTALLFOLDER"
                  ShortName="APS"
                  Directory="DesktopFolder" Icon="Password.ico" IconIndex="0" />
      </File>
    </Component>
    <Component Id="HtmlAgilityPack.dll" Guid="{119C78DC-EFE5-4C84-9583-17F3DE341EFC}">
      <File Id="HtmlAgilityPack.dll" Source="$(var.SourceDir)\HtmlAgilityPack.dll" KeyPath="yes" />
    </Component>
    <Component Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Guid="{D6DBE101-004B-4383-A5F5-7BF16EB0C0FC}">
      <File Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Source="$(var.SourceDir)\Microsoft.VisualBasic.PowerPacks.Vs.dll" KeyPath="yes" />
    </Component>
    <Component Id="rtools_setup_x64.exe" Guid="{622D3FCF-E3A0-4A12-99B0-E9D7F879CB16}">
      <File Id="rtools_setup_x64.exe" Source="$(var.SourceDir)\rtools_setup_x64.exe" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.application" Guid="{DB61CF4D-E785-44FD-BB95-D19F7D1619FB}">
      <File Id="AutomatedIDSystem.application" Source="$(var.SourceDir)\APS.application" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.exe.config" Guid="{3E1CD5E7-1AF7-47AF-9FE3-30CEC56EF950}">
      <File Id="AutomatedIDSystem.exe.config" Source="$(var.SourceDir)\APS.exe.config" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.exe.manifest" Guid="{07689029-E9E0-47C0-87D7-5A94FC959EDF}">
      <File Id="AutomatedIDSystem.exe.manifest" Source="$(var.SourceDir)\APS.exe.manifest" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.pdb" Guid="{4D3FBB60-6F55-439E-A88B-ADE7AF7A7459}">
      <File Id="AutomatedIDSystem.pdb" Source="$(var.SourceDir)\APS.pdb" KeyPath="yes" />
    </Component>
    <!--<Component Id="AutomatedIDSystem.vshost.application" Guid="{684D3AC6-FC03-4E87-944B-2D897169CDDE}">
    <File Id="AutomatedIDSystem.vshost.application" Source="$(var.SourceDir)\APS.vshost.application" KeyPath="yes" />
  </Component>-->
    <Component Id="AutomatedIDSystem.vshost.exe" Guid="{478284E1-999D-481D-91B4-4F8F15B998A6}">
      <File Id="AutomatedIDSystem.vshost.exe" Source="$(var.SourceDir)\APS.vshost.exe" KeyPath="yes" />
    </Component>
    <!--<Component Id="AutomatedIDSystem.vshost.exe.config" Guid="{099D79F8-370D-40FE-A6C2-0B76B6397FC7}">
    <File Id="AutomatedIDSystem.vshost.exe.config" Source="$(var.SourceDir)\APS.vshost.exe.config" KeyPath="yes" />
  </Component>-->
    <!--<Component Id="AutomatedIDSystem.vshost.exe.manifest" Guid="{48F07333-9C5B-4894-961D-531C26874531}">
    <File Id="AutomatedIDSystem.vshost.exe.manifest" Source="$(var.SourceDir)\APS.vshost.exe.manifest" KeyPath="yes" />
  </Component>-->
    <Component Id="Password.ico" Guid="{99391003-D8EE-4E6A-98E2-393F2ECE09D8}">
      <File Id="Password.ico" Source="$(var.SourceDir)\1Password.ico" KeyPath="yes" />
    </Component>
    <Component Id="setup.bat" Guid="{0460C522-A02B-4C8B-A0EE-34F1AFF677D1}">
      <File Id="setup.bat" Source="$(var.SourceDir)\setup.bat" KeyPath="yes" />
    </Component>

    <Component Id="netframework" Guid="{6BFA9239-38C7-4040-9487-6A5D20315CA7}">
      <File Id="netframework" Source="$(var.SourceDir)\dotnetfx452_full_x86_x64.exe" KeyPath="yes" />
    </Component>

    <!--    <Component Id="DesktopShortcut" Directory="DesktopFolder"> -->
    <Component Id="ApplicationShortcutDesktop" Guid="902B784B-B1F0-4629-AAC9-D46845734248">
      <Shortcut Id="ApplicationDesktopShortcut" Name="AppName" Description="APS" Target="[INSTALLFOLDER]APS.exe" WorkingDirectory="INSTALLFOLDER" />
      <RemoveFolder Id="DesktopFolder" On="uninstall" />
      <RegistryValue Root="HKCU" Key="Software\APS" Name="installed" Type="integer" Value="1" KeyPath="yes" />
    </Component>
    <!--</Component>-->

  </ComponentGroup>
</Fragment>

【讨论】:

  • 谢谢。我是 WiX 的新手。什么是专题栏目?
  • 我漏掉了一行是重要的一行
  • 我刚刚添加了更多示例
  • 我一定是做错了什么。我收到警告显示详细信息严重性代码描述项目文件行警告命名空间“schemas.microsoft.com/wix/2006/wi”中的元素“DirectoryRef”在命名空间“schemas.microsoft.com/wix/2006/wi”中具有无效的子元素“SetDirectpry”。预期的可能元素列表:命名空间“schemas.microsoft.com/wix/2006/wi”中的“组件、目录、合并”以及命名空间“##other”中的任何元素。
【解决方案2】:

您不应该自己为 DesktopFolder 赋值。 事实上,我很惊讶您竟然能够这样做。 DesktopFolder Property 由 Windows 安装程序在 FileCosting 期间自行设置(安装期间的标准操作)。

由于per-user and per-machine installation(安装上下文)的特殊概念由ALLUSERS property 的值控制,因此该属性的路径可以指向用户的桌面文件夹,也可以指向所有用户的桌面文件夹:

  • C:\Users\UserName\Desktop
  • C:\Users\Public\Desktop

这个相当无用的概念(安装上下文)会引起很多混乱。共识似乎是最好为每台机器安装设置 ALLUSERS=1。它们更容易管理。按用户安装允许为不同用户重复安装相同的设置,从而实现升级清理卸载修补硬。还有很多其他的问题,这里有一篇关于这个主题的文章(这是一个很好的阅读):http://www.indigorose.com/webhelp/sufwi/Concepts/Per-Machine_vs._Per-User_Installations.htm


如果我可以访问我的脚本存储库,我会为您提供一个真实的示例,但我目前没有。相反,请尝试这个众所周知的 Wix 教程(朝向底部):http://wix.tramontana.co.hu/tutorial/net-and-net/launch-the-internet

这只是教程内联中的代码:

<Property Id="URL" Value="http://www.something.com" />
<Shortcut Id="WebShortcut" Name="Web URL" Description="Jump to our website" Target="[URL]" />

这是另外两个示例:


如果您想通过 VBScript 创建文件夹,这里有一个简单的示例:

' Add a shortcut on the users desktop

Const DESKTOPFOLDER= 16

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(DESKTOPFOLDER) 
Set objFolderItem = objFolder.Self     

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objFolderItem.Path
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\MSDN.url")
objURLShortcut.TargetPath = "http://msdn.microsoft.com"
objURLShortcut.Save

请注意,您需要添加脚本以在卸载时删除此类快捷方式。要清理桌面上的所有用户,您需要使用ActiveSetup(可能在ActiveSetup 上也阅读this post)并注册清理作业,因为清理将在他们下次登录时进行。这可能是一个非常令人头疼的问题,因为他们可能会重新安装设置(相同或新版本),然后您需要取消任何待处理的每个用户的清理操作。


作为记录,这是一个节省时间的方法,您还可以通过依赖许多项目的默认属性值来大大简化您的 Wix XML。在这篇文章中查看更多详细信息:Syntax for guids in WIX?

快速示例。这就足够了:

<Component>
  <File Source="..\File.dll" />
</Component>

相对

<!-- Sample guid below, do not copy paste -->
<Component Id="File.dll" Guid="{12345678-1234-1234-1234-123456789ABC}">
  <File Id="File.dll" Name="File.dll" KeyPath="yes" Source="..\File.dll" />
</Component>

【讨论】:

  • 斯坦 - 谢谢。我很想通过电子邮件或其他方式与您保持联系。 WiX 是一个令人困惑的怪物
  • 是否迫切需要为每个用户添加快捷方式?如果真的需要,我通常使用自定义操作和 VBScripting 来做这些事情。否则,我会让每台机器的安装停止,让应用程序自己处理写入 HKCU 的所有数据。
  • 是的,我们正在使用 SCCM 在用户计算机上安装软件。但是我们需要他们桌面上的快捷方式而不是公开的(因为您需要管理员权限才能删除它)
  • 是否可以选择将快捷方式放在常见的开始菜单位置?哪里不会弄乱用户的桌面?程序 => 共享业务应用程序或类似的?
  • 我已经用更多细节更新了答案。我觉得读起来有点混乱,请点击 ActiveSetup 上的链接以获得更好的解释。
【解决方案3】:

我自己也遇到了麻烦。这是一个有效的项目模板:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Id="243604BF-62BC-4B9B-BFA7-8BD43DE096B9" Name="JTsApp" Language="1033" Version="1.4.0.0" Manufacturer="JT Pty Ltd" UpgradeCode="CEFF1611-50E1-4DC9-BC60-548A76312AA5">
    <Package Description="JTsApp Installer" Comments="JTsApp" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <Upgrade Id="{CEFF1611-50E1-4DC9-BC60-548A76312AA5}">
      <UpgradeVersion Minimum="1.0.4" IncludeMinimum="yes" Maximum="1.4.0" IncludeMaximum="yes" Property="OLDERVERSIONBEINGUPGRADED" />
    </Upgrade>

    <Icon Id="favicon.ico" SourceFile="JTsApp.ico"/>
    <Property Id="ARPPRODUCTICON" Value="favicon.ico" />

    <!--Ref: http://stackoverflow.com/questions/2058230/wix-create-non-advertised-shortcut-for-all-users-per-machine
    <Property Id="DISABLEADVTSHORTCUTS" Value="1" />-->

    <Feature Id="ProductFeature" Title="JTsApp" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ProgramMenuDir"/>
    </Feature>

    <Media Id="1" Cabinet="JTsApp.cab" EmbedCab="yes" />

    <!--<PropertyRef Id="NETFRAMEWORK40FULL" />
    <Condition Message="This application requires .NET Framework 4.0.">
      <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
    </Condition>-->

    <UIRef Id="MyWixUI_Minimal" />

    <InstallExecuteSequence>
      <RemoveExistingProducts After="InstallInitialize"/>
    </InstallExecuteSequence>

</Product>

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="DesktopFolder" SourceName="Desktop" />

    <Directory Id="ProgramMenuFolder" Name="Programs">
      <Directory Id="ApplicationProgramsFolder" Name="JTsApp">
        <Component Id="ProgramMenuDir" Guid="F8F34900-78DC-43FD-8C24-FC8A2401981D">
          <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
          <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\JTsApp" Type="integer" Value="1" Name="installed" KeyPath="yes" />
        </Component>
      </Directory>
    </Directory>

    <Directory Id="ProgramFilesFolder">
      <Directory Id="ManufacturerFolder" Name="JTs Pty Ltd">
        <Directory Id="INSTALLFOLDER" Name="JTsApp">
        </Directory>
      </Directory>
    </Directory>

  </Directory>

</Fragment>

<Fragment>
  <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    <!--Core Application-->
    <Component Id="TouchTypingWizard_Component">
    <File Id="TouchTypingWizard.exe" KeyPath="yes" Name="TouchTypingWizard.exe" Source="C:\1A\WiXsInstallerTemplate\SetupProject1\TouchTypingWizard\bin\Debug\TouchTypingWizard.exe" />

      <Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="JTsApp" WorkingDirectory="INSTALLDIR" Advertise="yes" Icon="favicon.ico" IconIndex="0" />
      <Shortcut Id="ExeShortcut" Directory="ApplicationProgramsFolder" Name="JTsApp" WorkingDirectory="INSTALLDIR"  Advertise="yes" Icon="favicon.ico" IconIndex="0" />

    </Component>

    <Component Id="JTsApp_DefaultIcon_RegKey">
      <RegistryValue Id="JTsApp_DefaultIcon_RegKey" Root="HKCR" Key="JTsApp\DefaultIcon" Value="" Type="string" KeyPath="yes" />
    </Component>

    <Component Id="JTsApp_DefaultIcon_exe_RegKey_Component">
      <RegistryValue Id="JTsApp_DefaultIcon_exe_RegKey" Root="HKCR" Key="JTsApp\DefaultIcon" Name="Default" Value="TouchTypingWizard.exe,1" Type="string" KeyPath="yes" />
    </Component>

  </ComponentGroup>
</Fragment>

</Wix>

您可以看到我尝试了很多东西,但我没有花时间缩小范围。我相信这几行是关键:

   <Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
 Name="JTsApp" WorkingDirectory="INSTALLDIR" Advertise="yes"
 Icon="favicon.ico" IconIndex="0" />
       <Shortcut Id="ExeShortcut" Directory="ApplicationProgramsFolder" Name="JTsApp" WorkingDirectory="INSTALLDIR"  Advertise="yes"
 Icon="favicon.ico" IconIndex="0" />

虽然,我不排除以下几行:

 <Component Id="JTsApp_DefaultIcon_exe_RegKey_Component">
           <RegistryValue Id="JTsApp_DefaultIcon_exe_RegKey" Root="HKCR" Key="JTsApp\DefaultIcon" Name="Default"
 Value="TouchTypingWizard.exe,1" Type="string" KeyPath="yes" />
         </Component>

不管怎样,这就是它有效的证明:

这里是安装项目目录中的文件:

解决方案如下所示:

^^ 注意:我引用了 C:\Program Files\WiX Toolset v3.8\bin\WixUIExtension.dll 并包含了 MyWixUI_Minimal。 wxs 文件。

这里是安装项目供您下载并确认它可以工作:

http://tempsend.com/09604C06D6

【讨论】:

  • 我在片段部分也有这个。它是否需要嵌套在 中?哪些行实际上创建了图标?我在 H:\Desktop 上需要它,如果 H:\Desktop 不可访问或不可用,请继续
  • 严重性代码说明项目文件行错误发现孤立组件“ProgramMenuDir”。如果这是一个产品,每个组件必须至少有一个父功能。要将组件包含在模块中,您必须将其直接包含为模块元素的组件元素,或通过 ComponentRef、ComponentGroup 或 ComponentGroupRef 元素间接包含。 APS D:\Projects\VSStudio\APSInstaller\Product.wxs 46
  • 把icon和wxs文件放在同一个目录下,我觉得SourceFile="$(var.SourceDir)\1Password.ico"是不对的。如果这不起作用,我将压缩一个工作 WIX 项目并将其上传到这个 arvo 的临时共享。
  • 我得到了桌面上的图标,但它是 C:\Users\Public\Desktop
  • 是的,我的脚本是 HKMU - 适用于所有用户。如果您希望“每个用户”不在机器范围内,则需要更改 InstallScope="perMachine"
猜你喜欢
  • 1970-01-01
  • 2011-06-21
  • 1970-01-01
  • 2013-03-14
  • 2011-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-26
相关资源
最近更新 更多