Wix 为所有用户/每台机器创建非广告快捷方式

发布于 2024-08-17 08:50:07 字数 424 浏览 3 评论 0原文

在 WIX 中,如何在所有用户配置文件中创建非广告快捷方式?到目前为止,我只能通过广告中的快捷方式来完成此任务。我更喜欢非广告的快捷方式,因为您可以转到快捷方式的属性并使用“查找目标”。

在教程中,我看到使用注册表值作为快捷方式的键路径。问题是他们使用 HKCU 作为根。当使用 HKCU 时,另一个用户卸载该程序(因为它是为所有用户安装的),注册表项将被保留。当我使用 HKMU 作为 root 时,出现 ICE57 错误,但当另一个用户卸载该程序时,该密钥被删除。尽管 HKMU 似乎表现正确(每个用户与所有用户),但我似乎被迫使用 HKCU。

当我尝试创建非广告快捷方式时,我收到各种 ICE 错误,例如 ICE38、ICE43 或 ICE 57。我见过的大多数文章都建议“忽略冰错误”。必须有一种方法可以创建非广告快捷方式,而不会产生 ICE 错误。

请发布工作示例的示例代码。

In WIX, how do you create a non advertised shortcut in the allusers profile? So far I've only been able to accomplish this with advertised shortcuts. I prefer non-advertised shortcuts because you can go to the shortcut's properties and use "find target".

In the tutorials I've seen use a registry value for the keypath of a shortcut. The problem is they use HKCU as the root. When HKCU is used, and another user uninstalls the program (since it's installed for all users) the registry key is left behind. When I use HKMU as the root I get an ICE57 error, but the key is removed when another user uninstalls the program. I seem to be pushed towards using HKCU though HKMU seems to behave correctly (per-user vs all-users).

When I try to create the non advertised shortcut I get various ICE error such as ICE38, ICE43, or ICE 57. Most articles I've seen recommend "just ignore the ice errors". There must be a way to create the non advertised shortcuts, without creating ICE errors.

Please post sample code for a working example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时间你老了 2024-08-24 08:50:07

抱歉,如果回答我自己的问题是不礼貌的。

最近,我偶然发现了有关 DISABLEADVTSHORTCUTS 属性 的信息。我创建了一个带有广告快捷方式的安装,并将 DISABLEADVTSHORTCUTS 属性设置为 1,这会生成非广告快捷方式。这会绕过 ICE43 错误,因为广告的快捷方式可以使用作为关键路径的文件。由于已设置 DISABLEADVTSHORTCUTS,Windows Installer 会将这些公布的快捷方式替换为常规快捷方式。

我将 Package 元素的 InstallScope 属性设置为“perMachine”。这会将 ALLUSERS 属性设置为 1。 ProgramMenuFolder 和 DesktopFolder 将解析为 All用户简介。

对于在ProgramMenuFolder 下创建的文件夹,有一个RemoveFolder 和RegistryValue 元素。我见过的例子(ex1ex2) 使用HKCU 作为RegistryValue 的根。我将此根更改为 HKMU ,根据值解析为 HKCU 或 HKLM所有用户。

简而言之,将 DISABLEADVTSHORTCUTS 设置为 1 时,您的广告快捷方式不会产生 ICE 错误,但在安装时会转换为非广告快捷方式。具有根 HKMU 的RegistryValue 对于KeyPath 来说是很好的,只要它不是非广告快捷方式的键路径即可。

<?xml version="1.0" encoding="utf-8"?>
<!-- This example is based on SampleFirst by Gábor DEÁK JAHN, Tramontána:
        http://www.tramontana.co.hu/wix/lesson1.php#1.3
    Original SampleFirst:
        http://www.tramontana.co.hu/wix/download.php?file=samples/samplefirst.zip&type=application/zip -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Name="Foobar 1.0" Id="YOURGUID-21F1-4026-ABD2-7CC7F8CE4D18" UpgradeCode="YOURGUID-AFA4-46C6-94AA-EEE3D104F903" Language="1033" Codepage="1252" Version="1.0.0" Manufacturer="Acme Ltd.">
        <Package Id="*" Keywords="Installer" Description="Acme's Foobar 1.0 Installer" Comments="Foobar is a registered trademark of Acme Ltd." Manufacturer="Acme Ltd." InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" InstallScope="perMachine" />
        <Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
        <Property Id="DiskPrompt" Value="Acme's Foobar 1.0 Installation [1]" />
        <Property Id="DISABLEADVTSHORTCUTS" Value="1" />
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="Acme" Name="Acme">
                    <Directory Id="INSTALLDIR" Name="Foobar 1.0">
                        <Component Id="MainExecutable" Guid="YOURGUID-3E4F-47A2-86F1-F3162E9C4798">
                            <File Id="FoobarEXE" Name="FoobarAppl10.exe" DiskId="1" Source="FoobarAppl10.exe" KeyPath="yes">
                                <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                                <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                            </File>
                        </Component>
                        <Component Id="HelperLibrary" Guid="YOURGUID-C7DA-4C02-A2F0-A6E089FC0CF3">
                            <File Id="HelperDLL" Name="Helper.dll" DiskId="1" Source="Helper.dll" KeyPath="yes" />
                        </Component>
                        <Component Id="Manual" Guid="YOURGUID-FF92-4BF4-A322-819A3B2265A0">
                            <File Id="Manual" Name="Manual.pdf" DiskId="1" Source="Manual.pdf" KeyPath="yes">
                                <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
            <Directory Id="ProgramMenuFolder" Name="Programs">
                <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
                    <Component Id="ProgramMenuDir" Guid="YOURGUID-D1C2-4D76-BA46-C6FA79862E77">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                        <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory>
            <Directory Id="DesktopFolder" Name="Desktop" />
        </Directory>
        <Feature Id="Complete" Level="1">
            <ComponentRef Id="MainExecutable" />
            <ComponentRef Id="HelperLibrary" />
            <ComponentRef Id="Manual" />
            <ComponentRef Id="ProgramMenuDir" />
        </Feature>
        <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" />
    </Product>
</Wix>

Sorry if it's bad etiquette to answer my own question.

Recently I stumbled upon the information on DISABLEADVTSHORTCUTS property. I created an install with advertised shortcuts and set the DISABLEADVTSHORTCUTS property to 1 which produced non-advertised shortcuts. This bypasses ICE43 errors because an advertised shortcut can use a file as a keypath. Because DISABLEADVTSHORTCUTS has been set Windows Installer will replace these advertised shortcuts with regular shortcuts.

I set the Package Element's InstallScope attribute to "perMachine". This sets the ALLUSERS property to 1. The values of ProgramMenuFolder and DesktopFolder will then resolve to the All Users profile.

For folders created under ProgramMenuFolder there is a RemoveFolder and RegistryValue element. The examples I've seen (ex1, ex2) use HKCU as the root for the RegistryValue. I changed this root to HKMU which resolves to HKCU or HKLM depending on the value of ALLUSERS.

In short, with DISABLEADVTSHORTCUTS set to 1 your advertised shortcuts will not produce ICE errors, but will be converted to non-advertised shortcuts when installed. A RegistryValue with root HKMU is fine for a KeyPath as long as it's not keypath for a non-advertised shortcut.

<?xml version="1.0" encoding="utf-8"?>
<!-- This example is based on SampleFirst by Gábor DEÁK JAHN, Tramontána:
        http://www.tramontana.co.hu/wix/lesson1.php#1.3
    Original SampleFirst:
        http://www.tramontana.co.hu/wix/download.php?file=samples/samplefirst.zip&type=application/zip -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Name="Foobar 1.0" Id="YOURGUID-21F1-4026-ABD2-7CC7F8CE4D18" UpgradeCode="YOURGUID-AFA4-46C6-94AA-EEE3D104F903" Language="1033" Codepage="1252" Version="1.0.0" Manufacturer="Acme Ltd.">
        <Package Id="*" Keywords="Installer" Description="Acme's Foobar 1.0 Installer" Comments="Foobar is a registered trademark of Acme Ltd." Manufacturer="Acme Ltd." InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" InstallScope="perMachine" />
        <Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
        <Property Id="DiskPrompt" Value="Acme's Foobar 1.0 Installation [1]" />
        <Property Id="DISABLEADVTSHORTCUTS" Value="1" />
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="Acme" Name="Acme">
                    <Directory Id="INSTALLDIR" Name="Foobar 1.0">
                        <Component Id="MainExecutable" Guid="YOURGUID-3E4F-47A2-86F1-F3162E9C4798">
                            <File Id="FoobarEXE" Name="FoobarAppl10.exe" DiskId="1" Source="FoobarAppl10.exe" KeyPath="yes">
                                <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                                <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                            </File>
                        </Component>
                        <Component Id="HelperLibrary" Guid="YOURGUID-C7DA-4C02-A2F0-A6E089FC0CF3">
                            <File Id="HelperDLL" Name="Helper.dll" DiskId="1" Source="Helper.dll" KeyPath="yes" />
                        </Component>
                        <Component Id="Manual" Guid="YOURGUID-FF92-4BF4-A322-819A3B2265A0">
                            <File Id="Manual" Name="Manual.pdf" DiskId="1" Source="Manual.pdf" KeyPath="yes">
                                <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
            <Directory Id="ProgramMenuFolder" Name="Programs">
                <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
                    <Component Id="ProgramMenuDir" Guid="YOURGUID-D1C2-4D76-BA46-C6FA79862E77">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                        <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory>
            <Directory Id="DesktopFolder" Name="Desktop" />
        </Directory>
        <Feature Id="Complete" Level="1">
            <ComponentRef Id="MainExecutable" />
            <ComponentRef Id="HelperLibrary" />
            <ComponentRef Id="Manual" />
            <ComponentRef Id="ProgramMenuDir" />
        </Feature>
        <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" />
    </Product>
</Wix>
二手情话 2024-08-24 08:50:07

尽管这篇文章相当旧,但它包含非常有用的信息并且看起来仍然活跃。我想指出的是,一般来说,您的快捷方式不需要虚拟注册表项! AFAIK 这是 WiX 教程,不是 MSI 或认证要求。这是一个没有 reg 键的示例:

<Fragment Id="Folders">
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="MyApp">
      </Directory>
    </Directory>
    <Directory Id="ProgramMenuFolder">
      <Directory Id="MyAppStartMenuDir" Name="MyApp"/>
    </Directory>
  </Directory>
</Fragment>
<Fragment Id="Components">
  <Component Id="MyAppComp" Directory="INSTALLFOLDER" ...>
    <!--The advertise flag below is to bypass ICE errors in WiX, the actual shortcut will not be advertises if those are disabled globally with DISABLEADVTSHORTCUTS-->
    <File ..." KeyPath="yes">
      <Shortcut Id="MyAppStartMenuLink" Directory="MyAppStartMenuDir" Advertise="yes" ... />
    </File>
    <RemoveFolder Id="StartMenuDirRemoved" Directory="MyAppStartMenuDir" On="uninstall" />
  </Component>
</Fragment>

请注意,这会将您的快捷方式与可执行文件放在一个组件中。如果这让您感到困扰,那么请使用虚拟注册表项(如解释得很好的已接受的自我答案中所示)。

Although this post is rather old it contains quite useful info and looks still active. I want to point out that in general you do NOT need a dummy registry key for your shortcut! AFAIK this is WiX tutorial thingy and is not MSI or certification requirement. Here is an example with no reg key:

<Fragment Id="Folders">
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="MyApp">
      </Directory>
    </Directory>
    <Directory Id="ProgramMenuFolder">
      <Directory Id="MyAppStartMenuDir" Name="MyApp"/>
    </Directory>
  </Directory>
</Fragment>
<Fragment Id="Components">
  <Component Id="MyAppComp" Directory="INSTALLFOLDER" ...>
    <!--The advertise flag below is to bypass ICE errors in WiX, the actual shortcut will not be advertises if those are disabled globally with DISABLEADVTSHORTCUTS-->
    <File ..." KeyPath="yes">
      <Shortcut Id="MyAppStartMenuLink" Directory="MyAppStartMenuDir" Advertise="yes" ... />
    </File>
    <RemoveFolder Id="StartMenuDirRemoved" Directory="MyAppStartMenuDir" On="uninstall" />
  </Component>
</Fragment>

Note that this will put your shortcut together with the executable in one component. If this bothers you then use dummy registry key (as in the very well explained accepted self answer).

糖粟与秋泊 2024-08-24 08:50:07

看看 从 MSI 到 WiX,第 10 部分 - 快捷方式,作者:Alex Shevchuk。

或者 Rob Menching 的博客文章 如何创建卸载快捷方式(并通过所有 ICE 验证)。

基本上 ICE57 相当烦人...但这是我用于桌面快捷方式的(似乎有效)代码:)

<Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
    <RegistryValue Id="RegShortcutDesktop" Root="HKCU" Key="SOFTWARE\My App\1.0\settings" Name="DesktopSC" Value="1" Type="integer" KeyPath="yes" />
    <Shortcut Id="desktopSc" Target="[APPLICATIONFOLDER]MyApp.exe" Directory="DesktopFolder" Name="My Applications" Icon="myapp.ico" IconIndex="0" WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
    <RemoveFolder Id="RemoveShortcutFolder" On="uninstall" />
    <Condition>DT_SHORTCUT=1</Condition>
</Component>

Take a look at From MSI to WiX, Part 10 - Shortcuts by Alex Shevchuk.

Or Rob Menching's blog post How to create an uninstall shortcut (and pass all the ICE validation).

Basically ICE57 is rather annoying... but here's the (seems to be working) code I'm using for Desktop shortcuts :)

<Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
    <RegistryValue Id="RegShortcutDesktop" Root="HKCU" Key="SOFTWARE\My App\1.0\settings" Name="DesktopSC" Value="1" Type="integer" KeyPath="yes" />
    <Shortcut Id="desktopSc" Target="[APPLICATIONFOLDER]MyApp.exe" Directory="DesktopFolder" Name="My Applications" Icon="myapp.ico" IconIndex="0" WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
    <RemoveFolder Id="RemoveShortcutFolder" On="uninstall" />
    <Condition>DT_SHORTCUT=1</Condition>
</Component>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文