Wix: Installing a shortcut to a URL with an icon

For months now an installer that I created using the InternetShortcut tag has been without a nice icon.

I decided to trawl the web and work out how to create a shortcut that could contain an icon.

It turns out you can actually use a standard Wix Shortcut IF you perform a few steps. First you need to define an icon like so:

<Icon Id="Shortcut_Icon.ico" SourceFile="<path to icon>" />

Note: The Id of the icon has a .ico extension. This is important as Wix does not generate a correct shortcut if this is not present.

Then, you need to setup a property which contains the URL you wish to have the shortcut launch:

<Property Id="Shortcut_Url" Value="http://the.url.you.would.like.launched" />

Finally, you need to create a shortcut that uses both the icon and the URL property:

<Shortcut Id="SampleShortcut" Directory="DesktopFolder" Name="Sample" WorkingDirectory="SampleDir"
Description="Launches Website." Target="[Shortcut_Url]" Icon="Shortcut_Icon.ico" />

The result is a shortcut that will launch the users default browser to the specified URL.