如何创建在用户桌面文件夹的快捷方式 [英] How can I create a shortcut on the Users Desktop folder

查看:131
本文介绍了如何创建在用户桌面文件夹的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与完整维克斯项目已更新为每craigster

Updated with Complete Wix Project as per craigster

<?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行

After following the direction that craigster and it's providing warnings for line 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

请告诉我,我需要做的,我的维克斯有一个快捷方式创建了H:。\Desktop

Please tell me what I need to do to my WIX to have a shortcut created on H:\Desktop

还有什么我需要删除,因为它是不必要/冗余

Also what do I need to remove because it's unnecessary/redundant.

推荐答案

这是有点像这个问题。

维克斯工具:在创建磁盘根目录下(系统盘或c:\)和副本中的文件

下面我充满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文件的内容。
不要忘了功能栏目

Also here what you need to add these three section to your wxs file. Don't forget the feature section

这加入的功能部分。

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



添加到您的目录栏目

Add this to your directories section

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



另外添加此CompenentGroup

Also add this 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>

您的文件应该是这样的。

Your file should look like this

<?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>



这篇关于如何创建在用户桌面文件夹的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆