windows 使用 Wix 安装程序在开始菜单程序中添加子文件夹的快捷方式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2004225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:41:32  来源:igfitidea点击:

Use Wix installer to add shortcut to subfolder in startmenu programs

windowsinstallerwixwindows-installerstartmenu

提问by Seth

I am trying to add my program shortcut to an existing folder in the start menu shortcuts. For example All Programs -> AppNameFolder -> AppNameVersionFolder -> AppShortcut

我正在尝试将我的程序快捷方式添加到开始菜单快捷方式中的现有文件夹中。例如All Programs -> AppNameFolder -> AppNameVersionFolder -> AppShortcut

In order to achieve this I added the extra lines:

为了实现这一点,我添加了额外的行:

          <Directory Id="ProgramMenuFolderApp" Name="App">
                <Directory Id="ProgramMenuDir" Name="APP 6.3.0">

to the following code in my .wxs file:

到我的 .wxs 文件中的以下代码:

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder" Name="Program Files">
            <Directory Id="CompanyName" Name="CompanyName">
                <Directory Id="App" Name="App">
                    <Directory Id="INSTALLDIR" Name="App 6.3.0">
                        <Component Id="MainExecutable" Guid="23FFE6FD-2BEA-4946-9875-8DBEEA5AAF55">
                            <File Id="AppEXE" Name="App.exe" Source="App.exe" KeyPath="yes">
                                <Shortcut Id="startmenu" Directory="ProgramMenuDir" Name="App 6.3.0" WorkingDirectory='INSTALLDIR' Icon="App.exe" IconIndex="0" Advertise="yes" />
                                <Shortcut Id="desktopApp" Directory="DesktopFolder" Name="App 6.3.0" WorkingDirectory='INSTALLDIR' Icon="App.exe" IconIndex="0" Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
        </Directory>
        <Directory Id="ProgramMenuFolder" Name="Programs">
            <Directory Id="ProgramMenuFolderApp" Name="App">
                <Directory Id="ProgramMenuDir" Name="App6.3.0">
                    <Component Id="ProgramMenuDir" Guid="BF266F76-192A-493E-B5C7-C54660E61D7D">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                        <RegistryValue Root="HKCU" Key="Software\CompanyName\App6.3.0" Type="string" Value="" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory>            
        </Directory>
        <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>

I get the following error when I try and build:

尝试构建时出现以下错误:

The directory ProgramMenuFolderApp is in the user profile but is not listed in the RemoveFile table.

The directory ProgramMenuFolderApp is in the user profile but is not listed in the RemoveFile table.

However, I do not want to remove the higher level folders when I uninstall, I only want to remove the App 6.3.0 folder and below.

但是,我不想在卸载时删除更高级别的文件夹,我只想删除 App 6.3.0 及以下文件夹。

How can I add the shortcut to a program subfolder in the start menu?

如何将快捷方式添加到开始菜单中的程序子文件夹?

采纳答案by Rob Mensching

If that message is coming from ICE64 then it is a warning. ICE warnings should be understood and if acceptable ignored. http://msdn.microsoft.com/en-us/library/aa369011(VS.85).aspxhas this to say:

如果该消息来自 ICE64,则它是一个警告。ICE 警告应该被理解,如果可以接受,可以忽略。http://msdn.microsoft.com/en-us/library/aa369011(VS.85).aspx有这样的说法:

ICE64 checks that new directories in the user profile are removed correctly in roaming scenarios.

Failure to fix a warning or error reported by ICE64 generally leads to problems in completely cleaning the computer during an uninstallation. When a roaming user who has installed the application logs on to a computer for the first time, all of the profile is copied down onto the computer. On advertisement (which takes place after the roaming profile download), the Installer verifies that the directory is already there and therefore does not delete it on uninstallation. This leaves the directory on the user's computer permanently.

ICE64 检查用户配置文件中的新目录是否在漫游场景中被正确删除。

未能修复 ICE64 报告的警告或错误通常会导致在卸载过程中彻底清理计算机时出现问题。当安装了该应用程序的漫游用户首次登录计算机时,所有配置文件都会被复制到计算机上。在广告(在漫游配置文件下载之后发生)时,安装程​​序会验证该目录是否已经存在,因此不会在卸载时将其删除。这将永久保留用户计算机上的目录。

It isn't clear why you would want to leave an empty "App" dir in the Start Menu. Seems like addressing the ICE issue is easiest. To do so, just add another RemoveFolder element to your ProgramMenuDir Component.

不清楚为什么要在“开始”菜单中留下一个空的“应用程序”目录。似乎解决 ICE 问题是最简单的。为此,只需将另一个 RemoveFolder 元素添加到您的 ProgramMenuDir 组件。