Format:Windows Shell Link (LNK)
| On this wiki | Facts · Code · Notes · Topics |
|---|
Windows shortcut (.lnk) files: a 76-byte ShellLinkHeader with CLSID 00021401-0000-0000-C000-000000000046, then optional target ID list, LinkInfo, string data and ExtraData blocks with 0xA000000x signatures.
A .lnk file records a shortcut target and often the target's timestamps, size, volume serial number and the machine's tracker identifiers, so it is a main artifact for what a user opened (also embedded in Jump Lists). Layout from liblnk (libyal, LGPL), documentation/Windows Shortcut File (LNK) format.asciidoc, which follows [MS-SHLLINK]. Little endian; times are FILETIME UTC.
Identification
- Starts with
4C 00 00 00(header size 76) followed by the CLSID01 14 02 00 00 00 00 00 C0 00 00 00 00 00 00 46(GUID 00021401-0000-0000-C000-000000000046).
ShellLinkHeader (76 bytes)
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | header size = 0x4C |
| 4 | 16 | link CLSID |
| 20 | 4 | link (data) flags |
| 24 | 4 | target file attribute flags |
| 28 | 8 | creation FILETIME (0 if unset) |
| 36 | 8 | last access FILETIME |
| 44 | 8 | last write FILETIME |
| 52 | 4 | target file size |
| 56 | 4 | icon index (signed) |
| 60 | 4 | ShowWindow value |
| 64 | 2 | hot key |
| 66 | 10 | reserved (zero) |
The timestamps and size are those of the target when the link was created or last updated.
Flags
0x01 HasTargetIDList, 0x02 HasLinkInfo, 0x04 HasName, 0x08 HasRelativePath, 0x10 HasWorkingDir, 0x20 HasArguments, 0x40 HasIconLocation, 0x80 IsUnicode (strings are UTF-16LE, else codepage), 0x100 ForceNoLinkInfo, 0x200 HasExpString, 0x1000 HasDarwinID, 0x4000 HasExpIcon, 0x20000 RunWithShimLayer, 0x40000 ForceNoLinkTrack, 0x80000 EnableTargetMetadata.
Missing from the list above (liblnk documentation @ 78ad043969): 0x400 RunInSeparateProcess, 0x2000 RunAsUser, 0x8000 NoPidlAlias, and from Vista on 0x100000 DisableLinkPathTracking, 0x200000 DisableKnownFolderTracking, 0x400000 DisableKnownFolderAlias, 0x800000 AllowLinkToLink, 0x1000000 UnaliasOnSave, 0x2000000 PreferEnvironmentPath, 0x4000000 KeepLocalIDListForUNCTarget (the source marks the meaning of most of these as unknown). Full table: Fact:Windows Shell Link (LNK)/enum/LinkFlags full table. The ExtraData blocks follow the last string in a fixed order: Fact:Windows Shell Link (LNK)/struct/ExtraData order and tracker block.
Order of the parts after the header
- Link target ID list (if HasTargetIDList): 2-byte size, then a shell item list (see libfwsi, libyal).
- LinkInfo (if HasLinkInfo): size, header size, location flags (0x1 volume ID and local base path, 0x2 common network relative link), offsets to volume information, local path, network share information, common path suffix, and (header size above 28/32) Unicode local and common paths. Volume information: size, drive type (0 unknown, 1 no root dir, 2 removable, 3 fixed, 4 remote, 5 CD-ROM, 6 RAM disk), drive serial number, volume label offset. The full path is local path + common path suffix, or network share name + common path suffix.
- String data in this order: description (name), relative path, working directory, command line arguments, icon location; each is a 2-byte character count and the characters.
- ExtraData blocks, each starting with a 4-byte size and a 4-byte signature, ended by a 4-byte zero terminal block.
ExtraData block signatures
| Signature | Block |
|---|---|
| 0xA0000001 | environment variables location (788 bytes) |
| 0xA0000002 | console properties |
| 0xA0000003 | distributed link tracker (96 bytes: machine NetBIOS name, droid volume and file GUIDs) |
| 0xA0000004 | console code page |
| 0xA0000005 | special folder location (16 bytes) |
| 0xA0000006 | Darwin properties (788 bytes) |
| 0xA0000007 | icon location (788 bytes) |
| 0xA0000008 | shim layer properties |
| 0xA0000009 | metadata property store |
| 0xA000000B | known folder location (28 bytes) |
| 0xA000000C | shell item identifiers list (Vista and later) |
Code & repositories
- https://github.com/libyal/liblnk @
78ad04396973196a0656509589b5662e7abc9ec0· license: LGPL-3.0
libyal C library and tools (lnkinfo) with the Windows Shortcut File format specification in documentation/.
Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-09
Pitfalls
- Working directory, arguments, icon location and path strings may contain unpaired UTF-16 surrogates.
- Windows 95 files can have a network share offset set although the flag is clear. Unverified beyond the source note.
- A zero-length LinkInfo and an extra data block one byte too small are listed as corruption scenarios in the source.
See also
Format:Windows Jump Lists (embed LNK files), Format:Windows Prefetch, Format:Windows Registry hive (REGF).