Windows Internet Shortcuts (.url)

You may notice, that in Windows usual shortcuts (.lnk) and Internet Shortcuts (.url) looks mostly the same and are created with a single action and single dialog box. Actually they are completely different things.

While the .lnk has binary format known only to Windows internal mechanisms (we can create and change it from code only through COM), the .url files are... .ini. Despite the visually same creation method, usual .lnk can't handle the URLs (except the default call to web browser with URL in arguments).

The Internet Shortcut Inside

Internet shortcut has extension .url. The icon of such file in shell is browser icon (except the case when the icon is specified directly).

Inside of the Internet shortcut there is an INI content. Primitive internet shortcut looks so:

[InternetShortcut]
URL=http://brokenevent.com/

There is only one known section InternetShortcut with following values:

  • URL - the URL to open. Required. May use also file:// protocol for local files.
  • IconFile - absolute path to file containing the icon for shortcut. Optional. Supports .ico and executable files (.exe, .dll).
  • IconIndex - index of icon in file, pointed by IconFile. Optional. Meaningless without the IconFile.
  • HotKey - number value of hotkey. Optional.

The HotKey is produced from bitwise OR of integer value of key from System.Windows.Forms.Keys and the modifier key:

    public enum ModifierKey
    {
      Shift = 1 << 8, 
      Ctrl = 1 << 9, 
      Alt = 1 << 10, 
      Win = 1 << 11, 
    }

The line separator between values is usual Windows \13\10 (known as \r\n or CRLF).