Wix-网站快捷图标

7

我是新手在wix上操作。需要创建一个到本地网站的快捷方式。

它可以正常工作并创建快捷方式,但是在开始菜单和桌面上不显示任何图标...该网站有favicon文件,当我打开网站时,我可以看到它-只是在快捷方式中无法看到它。我尝试通过Google搜索util:InternetShortcut,但没有找到好的答案...

我使用的代码是:

<DirectoryRef Id="ApplicationProgramsFolder">
  <Component Id="ApplicationShortcutBBBApp" Guid="---">
    <util:InternetShortcut Id="ApplicationStartMenuShortcutBBBApp"
                    Name="BBB"
                    Target="http://localhost/BBB"/>
    <util:InternetShortcut Id="ApplicationDesktopShortcutBBBApp"
                    Name="BBB"
                    Directory="DesktopFolder"
                    Target="http://localhost/BBB"/>
    <RegistryValue Root="HKCU" Key="Software\Microsoft\BBB" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
  </Component>
</DirectoryRef>
4个回答

22

对于那个问题,有一个更简单的解决方案。不必使用 InternetShortcut,只需使用普通的快捷方式,并使用一个技巧设置目标为网址即可。

<SetProperty Id="URL" Value="http://yourpage.com" Sequence="execute"  Before="CreateShortcuts" />


<Shortcut Directory="DesktopFolder" Id="WebShortcut" Name="Your Page" Description="Your Page Description" Target="[URL]" Icon="IconDesktop">
    <Icon Id="IconDesktop" SourceFile="images\icon.ico" />
</Shortcut>

“SetProperty”可以放在产品标签中的某个位置。将“InternetShortcut”替换为“Shortcut”。有一个名为[URL]的属性作为目标非常重要,它可以是一个URL。直接写不起作用。可能会在Heat / Candle / Light中出现警告,可以忽略它们。


适合我,看起来是最简单的解决方案。 - Gal Shadeck
1
太棒了。谢谢。这种方法比我刚刚花了30分钟试图理解为什么util:InternetShortcut无法创建任何URL快捷方式要清晰得多。 - c00000fd

1

InternetShortcut不支持像普通快捷方式一样指定图标。有一个开放功能请求。从技术上讲,Windows中的IUniformResourceLocator快捷方式不支持图标,但IShellLink快捷方式支持。


有没有其他方法来为网站的快捷方式定义图标?(使用wix) - TamarG
1
一个可能的解决方法似乎在@BobArnson提到的功能请求中有所描述。 - Yan Sklyarenko
1
Internet快捷方式支持图标,但是它们是通过IPropertySetStorage接口而不是IUniformResourceLocator实现的。请参阅http://msdn.microsoft.com/en-us/library/bb776784(v=vs.85).aspx#Intshcut_Props。 - Ohad Schneider

0
在Wix中,您可以通过InternetShortcut Element (Util Extension)创建带有图标的InternetShortcut。
以下是我正在开发的应用程序中添加带有图标的网站链接的示例,通过<InternetShorcut>元素将该链接放置在桌面和开始菜单上。
请注意,您可能需要在元素名称前加上“util”前缀,如下所示,尽管我没有这样做:<util:InternetShortcut>
<Directory Id="ProgramMenuFolder" Name="ProgramMenuFolder">
    <Directory Id="ProgramMenuFolder.MyApplicationName" Name="MyApplicationName">
        <Component Id="Component.Uninstall" Guid="215c7bec-7967-43e6-8f01-72c27fbb2a98">
            <CreateFolder/>
            <RemoveFolder Id="ProgramMenuFolder.MyApplicationName" On="uninstall"/>
            <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
                <RegistryValue Value="0" Type="string" KeyPath="yes"/>
            </RegistryKey>
        </Component>
        <Component Id="InternetShortcut" Guid="215c7bec-7967-43e6-8f01-72c22e505f09">
            <InternetShortcut 
                IconFile="[INSTALLDIR]\icon.ico" 
                IconIndex="0" 
                Name="Admin Page" 
                Id="InternetShortcut" 
                Target="http://localhost:4444" 
                Type="link" 
                xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
            <CreateFolder/>
            <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
                <RegistryValue Value="0" Type="string" KeyPath="yes"/>
            </RegistryKey>
        </Component>
    </Directory>
</Directory>
<Directory Id="DesktopFolder" Name="DesktopFolder">
    <Component Id="InternetShortcut.1" Guid="B27DF351-6EDA-4BEF-A3AC-F12313260203">
        <InternetShortcut
            IconFile="[INSTALLDIR]\icon.ico" 
            IconIndex="0" 
            Name="Admin Page" 
            Id="InternetShortcut.1" 
            Target="http://localhost:4444" 
            Type="link" 
            xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
        <CreateFolder/>
        <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
            <RegistryValue Value="0" Type="string" KeyPath="yes"/>
        </RegistryKey>
    </Component>
</Directory>
<Feature Id="Complete" Title="Complete" Absent="allow" Level="1">
    <ComponentRef Id="InternetShortcut"/>
    <ComponentRef Id="InternetShortcut.1"/>
</Feature>

另外,请参阅如何:创建网页快捷方式


0
有点晚回答,但我也需要做同样的事情。我采用的方法是使用iniFile元素来编写一个url文件。
这种方法有两个值得注意的地方:
  1. 由于快捷方式位于桌面上,而图标文件位于文件系统的其他位置,因此我需要创建单独的组件来部署图标文件。
  2. 如果以普通用户身份运行MSI并启用UAC,则不会为快捷方式设置图标。在安装之前禁用UAC后,图标被正确设置。

    <Fragment>
    <DirectoryRef Id="DesktopFolder">
        <Component Id="ProductInternetShortcut" Guid="{YOUR_GUID_HERE}" >
            <IniFile Id="url_name"
                Action="addLine"
                Directory="DesktopFolder"
                Section="InternetShortcut"
                Name="ProductInternetShortcut.url"
                Key="URL"
                Value="https://my.url.com/" />
    
            <IniFile Id="url_target"
                Action="addLine"
                Directory="DesktopFolder"
                Section="InternetShortcut"
                Name="ProductInternetShortcut.url"
                Key="Target"
                Value="https://my.url.com/" />
    
            <IniFile Id="url_idlist"
                Action="createLine"
                Directory="DesktopFolder"
                Section="InternetShortcut"
                Name="ProductInternetShortcut.url"
                Key="IDList"
                Value=" " />
    
            <IniFile Id="url_HotKey"
                Action="addLine"
                Directory="DesktopFolder"
                Section="InternetShortcut"
                Name="ProductInternetShortcut.url"
                Key="HotKey"
                Value="0" />
    
            <IniFile Id="url_icon"
                Action="addLine"
                Directory="DesktopFolder"
                Section="InternetShortcut"
                Name="ProductInternetShortcut.url"
                Key="IconFile"
                Value="PATH_TO_ICON_FILE_ON_WORKSTATION" />
    
            <IniFile Id="url_iconIndex"
                Action="addLine"
                Directory="DesktopFolder"
                Section="InternetShortcut"
                Name="ProductInternetShortcut.url"
                Key="IconIndex"
                Value="0" />
    
            <RegistryValue Root="HKCU" Key="Software\COMPANY\PRODUCT" Name="installed" Type="integer" Value="1" KeyPath="yes" />
        </Component>
    </DirectoryRef>
    <DirectoryRef Id="ProductFolder">
        <Component Id="ShortcutIcons" Guid="{YOUR_GUID_HERE}">
            <File Id="filProductIcons" KeyPath="yes" Source="PATH_TO_ICON_FILE_ON_DEVELOPER_MACHINE" />
        </Component>
    </DirectoryRef>
    </Fragment>
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接