zoukankan      html  css  js  c++  java
  • WiX安装选项开始菜单项

    参考文档: How To: Create a Shortcut on the Start Menu,How To: Create an Uninstall Shortcut

    制作的安装程序安装后,都要在开始菜单上生成一个应用程序的菜单,通常包括调用应用程序的快速入口和卸载应用程序项。下面取一个例子来看:

    <?xml version="1.0" encoding="utf-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Product Id="a960cf35-0779-43e8-923b-35638f2bfc42" Name="Minimal" Language="2052" Version="1.0.0.0" Manufacturer="Geffzhang" UpgradeCode="0bf7e020-5bbd-4a06-8e39-e715999edbf5">
        <Package InstallerVersion="200" Compressed="yes" Description="Minimal Windows Installer Sample" Comments="This installer database contains the logic and data required to install Minimal Windows Installer Sample." />
        <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
        <Property Id="EnableEV" Value="1">
        </Property>
        
        <Condition Message="你必须有管理员权限才能安装应用程序"><![CDATA[Privileged]]></Condition>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="Minimal">
              <Component Id="Component1" Guid="{1781A625-8ACB-45E7-A8BA-219D81760B2E}">
                <CreateFolder />
                <Environment Id="TestMinVar" Action="set" Part="all" Name="MinEnvVar" Permanent="no" System="yes" Value="8" />
                <File Id="File_Payload" Source="payload.txt" KeyPath="yes" />
              </Component>
              <Directory Id="GAC" Name="GAC">
                <Component Id="RTGACTest" Guid="22887611-B13E-41EE-897C-D78830E68AEB" DiskId="1">
                  <!-- Runtime, assembly in GAC -->
                  <File Id="F_RT_GACTEST"  LongName="GACTest.dll" Source="..\build\GACTest.dll" KeyPath="yes" Assembly=".net" />
                </Component>
              </Directory>
              <Component Id="DTGACTest" Guid="FB935B7D-D2BD-4B83-A26C-A9376EBA0915" DiskId="1">
                <!--Design-time, private assembly-->
                <File Id="F_DT_GACTest" LongName="GACTest.dll" Source="..\build\GACTest.dll" KeyPath="yes" />
                <Registry Id="R_DT_MyControl_AssemblyFolders" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\[ProductName]" Value="[$DTGACTest]" Type="string" />
              </Component>
            </Directory>
          </Directory>
          
          <Directory Id="ProgramMenuFolder">
            <Directory Id="MinimalStartMenuFolder" Name="Minimal">
              <Component Id="StartMenuFolder" Guid="B3AEC4C4-3F8E-4865-B87A-B750533776B5" >
                <Shortcut Id="ApplicationStartMenuShortcut" 
                          Name="Minimal Test"  Target="[INSTALLLOCATION]payload.txt"
                 WorkingDirectory="INSTALLLOCATION"/>
                <Shortcut Id="UninstallProduct"
                      Name="Uninstall Minimal"
                        Description="Uninstalls My Application"
                      Target="[System64Folder]msiexec.exe"
                      Arguments="/x [ProductCode]"/>
    
                <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
                <RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplicationName" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
              </Component>
            </Directory>
          </Directory>
        </Directory>    
    
        <Feature Id="ProductFeature" Title="Minimal" Level="1">
          <ComponentRef Id="Component1" />
          <ComponentRef Id="DTGACTest"/>
          <ComponentRef Id="RTGACTest" />
          <ComponentRef Id="StartMenuFolder"/>
        </Feature>
        
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
        <UIRef Id="WixUI_InstallDir" />
        <UI />
      </Product>
    </Wix>

    上面例子中开始菜单项的内容是这一段:

    <Directory Id="ProgramMenuFolder">
            <Directory Id="MinimalStartMenuFolder" Name="Minimal">
              <Component Id="StartMenuFolder" Guid="B3AEC4C4-3F8E-4865-B87A-B750533776B5" >
                <Shortcut Id="ApplicationStartMenuShortcut" 
                          Name="Minimal Test"  Target="[INSTALLLOCATION]payload.txt"
                 WorkingDirectory="INSTALLLOCATION"/>
                <Shortcut Id="UninstallProduct"
                      Name="Uninstall Minimal"
                        Description="Uninstalls My Application"
                      Target="[System64Folder]msiexec.exe"
                      Arguments="/x [ProductCode]"/>
    
                <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
                <RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplicationName" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
              </Component>
            </Directory>
          </Directory>
        </Directory>    
    开始菜单项和要安装的应用程序要分开放在不同的Directory里面,ProgramMenuFolder是标准的Windows开始菜单,第二个Directory将是在windows开始菜单下创建的一个菜单项,我们把它命名
    为Minimal,菜单的快捷方式包括三个元素:一个是Component 元素是WiX安装元素的原子单位,Component元素下的Shortcut就是快捷菜单项了,RemoveFolder 元素保证在卸载应用程序的时候
    做相关的清理工作。上面的例子中有两个快捷方式,一个是Minimal Test,另一个是Uninstall Minimal,这两个就是Windows开始菜单中所看到的菜单项了。
    Windows Installer System64Folder 属性在32位的机器上被解析为System32 目录,在64位的机器上被解析为 SysWow64 目录.

    欢迎大家扫描下面二维码成为我的客户,为你服务和上云

  • 相关阅读:
    lr 增强窗格中,如何生成调试信息?
    lr 自带的例子,如何进行关联,通过代码的函数进行实现
    lr11 录制脚本时候,无法自动启动ie,查了网上很多方法都未解决?
    loadrunner11 录制脚步不成功,在录制概要出现“No Events were detected”,浮动窗口总是显示“0 Events”,解决办法
    loadrunner11 安装及破解教程来自百度文库
    安装loadrunner11 ,出现如下错误如何解决?
    回收站数据删除了,如何进行恢复?
    网管工作方面——————打印机删除了然后开机重启他依然存在,如何解决
    Windows 不能在 本地计算机 启动 SQL Server 服务 错误代码126
    Sorry, the page you are looking for is currently unavailable. Please try again later. Nginx
  • 原文地址:https://www.cnblogs.com/shanyou/p/1359120.html
Copyright © 2011-2022 走看看