New WiX feature: Internet shortcuts
A common request on wix-users is how to create shortcuts to a Web site. MSI’s Shortcut table and CreateShortcuts action don’t support targets that point to URLs like http://www.joyofsetup.com/. A shortcut’s target can point only to a feature (for advertised shortcuts) or a file or directory (for unadvertised shortcuts).
You can fake a shortcut to a URL by using the IniFile table to create a .url file. It’s a bit of a hack, given that the format of .url files isn’t explicitly documented and is therefore subject to change. (Granted, it’s not likely to change, because that would break a lot of existing applications.)
I needed URL shortcuts for Train Simulator so I wrote a custom action to create them. I then added authoring support to the WixUtilExtension compiler extension. With reviews from Heath and Peter, I checked in the work today. You’ll see it in the next weekly build of WiX v3.
The authoring is similar to, but simpler than, a standard shortcut. Here’s the attribute schema reference from WiX.chm:
<td width="54" valign="top">
<strong>Type</strong>
</td>
<td width="260" valign="top">
<strong>Description</strong>
</td>
<td width="80" valign="top">
<strong>Required</strong>
</td>
<td width="59" valign="top">
String
</td>
<td width="250" valign="top">
Unique identifier in your installation package for this Internet shortcut.
</td>
<td width="85" valign="top">
Yes
</td>
<td width="62" valign="top">
String
</td>
<td width="244" valign="top">
Identifier of the directory where the shortcut should be created.
</td>
<td width="89" valign="top">
Yes
</td>
<td width="64" valign="top">
String
</td>
<td width="241" valign="top">
The name of the shortcut file, which is visible to the user. (The .lnk extension is added automatically and by default, is not shown to the user.)
</td>
<td width="91" valign="top">
Yes
</td>
<td width="65" valign="top">
String
</td>
<td width="239" valign="top">
URL that should be opened when the user selects the shortcut. Windows opens the URL in the appropriate handler for the protocol specified in the URL. Note that this is a formatted field, so you can use [#fileId] syntax to refer to a file being installed (using the file: protocol).
</td>
<td width="95" valign="top">
Yes
</td>
Here’s what a simple http shortcut looks like:
<util:InternetShortcut
Id="Home"
Directory="DesktopFolder"
Name="Joy of Setup"
Target="http://joyofsetup.com" />
You can also create shortcuts to resources using non-http protocols:
<util:InternetShortcut
Id="ARP"
Directory="ProgramMenuFolder"
Name="ARP"
Target="file://[%WINDIR]\Help\addremov.chm" />
Internet shortcuts are needed, among other reasons, for Vista’s Game Explorer. More on that in a future entry.