Introduction
A .lnk file is a Windows
shortcut: the icons on the desktop and in the Start menu that open a program, file or
folder stored somewhere else. Windows hides the extension, so a shortcut shows only its
name and an arrow on its icon. Microsoft documents the format as the Shell Link Binary
File Format, MS-SHLLINK.
As well as the target’s path, a shortcut records the target’s size and times, the volume it was on and often the name of the computer. Forensic investigators read shortcuts to learn which files were opened and when.
A .lnk file dropped on any page opens in the explorer. It shows the
target (from LinkInfo, and rebuilt from the shell items), the strings, the link flags,
the shell items, the extra data blocks, the link tracking identifiers and the property
store, and marks each part in the file’s bytes; a row in each table selects its bytes
and a click on the bytes selects the field. Every field has a name and, where the
value has a meaning, the meaning. A file named .lnk that is not a shell link
(linker scripts of that name are common) is reported as not a shell link, and a damaged
or cut-off shortcut is read as far as it goes, the rest shown as labelled bytes with the
reason.
Structure
A shortcut starts with a 76-byte ShellLinkHeader. Its first four bytes give the header
size, 0x4C, followed by a fixed class ID, so every shortcut starts with
4C 00 00 00 01 14 02 00. The header
then holds the link flags, the target’s file attributes, its creation, access and write
times, its size, the icon index, the window state to open it in and a hot key. All values
are little-endian.
The link flags say which optional parts follow. The LinkTargetIDList holds the target as a list of shell items. LinkInfo holds the local path and volume details, or the network share. StringData holds counted strings: a description, a relative path, the working directory, command line arguments and the icon’s location. Extra data blocks close the file, such as the tracker block with the machine name and the environment variables block.
0ShellLinkHeader size, class ID, flags, times, file size, icon, show command76 bytes76LinkTargetIDList the target as shell items, if flaggedvaries…LinkInfo volume and local path, or network share, if flaggedvaries…StringData description, paths, arguments, icon locationvaries…ExtraData blocks, ending with a 4-byte terminatorvaries
Versions and variants
MS-SHLLINK describes one format, version-less: a fixed header, then the parts the flags announce. Shortcuts from different Windows versions differ in what they hold, not in this frame:
- Windows 95, 98, NT 4 write ANSI strings, file entry shell items with a
long name followed by the 8.3 name, no extension blocks and often no ExtraData terminator;
the file attribute value can carry
0x8000; the LinkInfo can hold stale bytes in its unused network offset. - Windows XP and 2003 write file entry shell items with extension blocks,
among them
0xBEEF0004version 3 with the long name. The tracker block and Unicode strings occur in shortcuts of this era (and in some from earlier systems; the IsUnicode flag, not the version, says which strings are used). - Windows Vista and later add the KnownFolderDataBlock, the property store
and the VistaAndAboveIDList blocks and version 7, 8 and 9 of the
0xBEEF0004block.
Where shortcuts turn up
Windows writes a shortcut to the user’s Recent folder whenever a file is
opened from Explorer or an application, so the folder is a record of recent documents.
Jump lists, the per-application lists of recent and pinned items that
Windows 7 and later show on the taskbar, store shortcuts too. An
.automaticDestinations-ms file is an OLE compound file whose streams named in
hexadecimal each hold a complete .lnk file, next to a DestList stream
with entries (object IDs, host name, time, pin state, path). A
.customDestinations-ms file is a header (version 2, a category count), then
categories of shell objects, each a Shell Link class ID followed by a shortcut, and each
category ends with the footer 0xBABFFBAB. (Source: the libyal jump lists
documentation.) This site does not have a Jump List viewer yet.
Internet shortcuts are a different format that shares the idea:
.url files are INI text and
.webloc files are property lists.
Not described
Known, not yet covered
- Viewer: Jump List files (
.automaticDestinations-msand.customDestinations-ms) are not decoded; libyal documents both. The shortcuts inside them would open with this viewer once extracted. - Viewer: checked on real files since the second re-check: 58 shortcuts made by
Windows 11 for files, folders, a drive, ZIP contents, UNC paths, FTP addresses (with user, password
and port), web addresses,
search-ms:, Control Panel items and categories, Libraries, This PC folders, known folders, an app inshell:AppsFolderand shortcuts carrying console, console code page, Darwin, shim and special folder blocks (the blocks were handed to the shell, which wrote them back). Still checked only on files built from libfwsi’s tables, because no real shortcut here holds them and no device or program is on the VM: the Game Folder, Acronis TIB, Web Sites, MTP, SolidWorks, Hyper-V and unknown-class items (0x01, 0x4C, 0x4E, 0x67, 0x76, 0xFF), the Portable Devices, Search Folder and Removable Drives delegate data, the0xBEEF000Bblock (libfwsi’s own layout for it has doubtful gaps, which the viewer reads as zero runs), the Windows XP form of the compressed folder item and the less common property value types. The viewer’s reading of those could differ from a real file. - Reference: libfwsi lists 16 delegate folders and all 16 are named; it gives layouts for only five of them, so the inner data of the others (DLNA Media Servers, Recent Files, Frequent Places, Libraries, Portable Media Devices and so on) shows as bytes.
- Reference and viewer: property key names are Wine’s
propkey.h(1,067 keys) plus the 9 keys of Microsoft’s property pages (MicrosoftDocs/win32, 1,029 pages) that Wine lacks. A key that is in neither list shows as a GUID and a number; Microsoft’s SDK header itself was not available as one file to compare. - Reference and viewer: the winshl-kb lists name 187 of 226 shell folder GUIDs and 65 of 77 Control Panel item GUIDs (the rest have no name on their pages), and all 124 KNOWNFOLDERID GUIDs are named. The unnamed ones show as GUIDs.
Unknown
- Reference and viewer: Microsoft does not publish the shell item layouts
(MS-SHLLINK calls an item opaque). Everything on the
shell items page comes from libfwsi and from real files,
and libfwsi itself marks many fields unknown: the two bytes after a Windows 95 volume name
(they differ from file to file), the first byte of file entries, the unknown fields of
0xBEEF0000,0001,000A,0013,0016,0017,0025,0026,0027,0029, the layout of0xBEEF0008and000B, and the URI item’s flags and data. They are shown labelled “Unknown” with their bytes. - Reference: what bit 15 of the file attributes (
0x8000) means in Windows 95 shortcuts is not documented anywhere read (the modern constant is the ReFS integrity stream flag; searched: MS-SHLLINK, liblnk, libfwsi, Microsoft Learn). The meaning of the link flagsDisableKnownFolderTrackingtoKeepLocalIDListForUNCTargetis given by MS-SHLLINK only in one line each; no source says exactly what Windows does with them. - Reference: the property set
{46588AE2-4CBC-4338-BBFC-139326986DCE}is not named by any source read (liblnk lists it as unknown; winshl-kb’s property set list and Wine’s and Microsoft’s property key lists have no entry for it); its property 4 looks like a user SID, and it appears in shortcuts written by Windows 11 for programs (property store block of every file shortcut made on the VM).
Links
Software
- Windows File Explorer – follows shortcuts and edits them in their Properties (Windows)
- LECmd – Eric Zimmerman’s shortcut parser for forensic work (Windows)
Developers
- liblnk – library with Python bindings that reads shortcut files (C)
Reference
- MS-SHLLINK – Microsoft’s specification of the Shell Link binary file format
- MS-PROPSTORE – Microsoft’s specification of the property store held in the PropertyStoreDataBlock
- libfwsi – Joachim Metz’s documentation of Windows shell items (reverse-engineered)
- Windows Shortcut File (LNK) format – Joachim Metz’s description of the format, including the variants older than MS-SHLLINK covers
- Jump lists format – libyal’s description of the automatic and custom destinations files that embed shortcuts