Skip to content

How to Read a Windows Shortcut (.LNK) File Without Opening Its Target

Read a Windows .LNK file with LECmd, check its recorded target path, and tell the shortcut’s own dates apart from the target dates stored inside.

By Sourabh7 min read

You find a file called notes.lnk, but the document it points to is nowhere in the folder. You can read the shortcut itself to see what Windows saved about the target. Work from a copy and open that copy in a shortcut parser. A parser reads the file’s fields without asking Windows to follow the link.

Start with one question. What does this shortcut point to? Once you can answer that, check which file each timestamp describes. You’ll make a practice shortcut for a file you know, then use a published sample to see where those details live inside the link.

Use a Windows practice account with LECmd available. The following commands make a new temporary folder, write a harmless text file, and save a shortcut to it. PowerShell uses Windows Script Host to create the link. Run this on a machine where that feature is available.

powershell
$lab = Join-Path $env:TEMP ('LnkLab-' + [guid]::NewGuid())
New-Item -ItemType Directory -Path $lab | Out-Null
$target = Join-Path $lab 'notes.txt'
$shortcut = Join-Path $lab 'notes.lnk'
Set-Content -LiteralPath $target -Value 'ForensicSpot shortcut exercise'
$shell = New-Object -ComObject WScript.Shell
$link = $shell.CreateShortcut($shortcut)
$link.TargetPath = $target
$link.Save()
$shortcut

The last line prints the path to the shortcut. $target is the document’s full path, and $shortcut is the path to the link we just wrote. Keep both in your notes. When you run the parser, you can compare the path it reports with the path you assigned instead of guessing whether it found the right file. The two files have similar names, but they hold different things. The text file contains the sentence you wrote. The shortcut contains a reference to that file and may also hold other details about its target. The LNK file glossary explains the format.

Open notes.lnk in the parser. The target file is separate.

Make a working copy when reviewing a shortcut that came from an acquisition. A SHA-256 hash lets you compare the copy’s bytes with its reference. The digital first response lesson explains how that check fits into handling digital evidence. For this exercise, you can use the shortcut you just made.

Read the Shortcut Without Following It

In the same PowerShell session, change to the directory that contains LECmd.exe and run this command. If you opened a new session, substitute the full path that PowerShell printed for $shortcut. Put the path in quotes if it contains spaces.

powershell
.\LECmd.exe -f $shortcut

The -f option tells LECmd to examine one file. Start with the path it found in the link. For the practice shortcut, look for your temporary folder and notes.txt. Then look for the dates the tool associates with the shortcut file and the dates it associates with its target. Exact labels and available fields depend on the parser version and what the link contains.

You can also follow along with Microsoft’s worked Shell Link specification example, titled Shortcut to a File. We reconstructed its published bytes and read the header and the local base path directly. The local base path in that sample is C:\test\a.txt. Its header stores matching target creation, access, and write times of September 12, 2008, at 20:27:17.101 UTC.

We read Microsoft’s published sample bytes to check the local base path and the three timestamps stored for its target.

A path can be stored in more than one place. For example, this sample has a local base path and a relative path. A relative path describes where to look from a starting point. If the fields disagree or a parser gives you only part of a path, record the fields it actually displayed and which one you used in your notes. Some shell links refer to locations other than ordinary local files.

Verify the Path in the Published Sample

If you want to check what a parser is reading, an offset is just a position counted from the start of the file. In Microsoft’s sample, the local path starts at offset 0x138. The bytes there spell C:\test\a.txt. The zero byte after the last letter marks the end of the string in this sample.

The exact bytes in Microsoft’s example decode to the stored path. The offset is specific to this sample.

That offset is specific to this file. Parts of a Windows shortcut are optional and can vary in length. In a different shortcut, use the parser or follow the offset fields defined by the format. Searching for .txt in a hex view may turn up a filename, but it does not tell you which field held it.

You can cross-check the dates independently, too. The header’s eight-byte target creation, access, and last-write fields start at 0x1C, 0x24, and 0x2C. Microsoft’s sample has the same bytes in all three fields. Those bytes are a Windows FILETIME value, which represents time as 100-nanosecond ticks since January 1, 1601, UTC. The identical three values explain why the dates agree here. Other shortcuts can hold different values or leave a field unset.

If the Filename or Target Looks Wrong

File Explorer can display a shortcut without showing the .lnk suffix. Use Get-ChildItem -LiteralPath $lab | Select-Object Name to see the filenames in the exercise folder. The file that goes into the parser ends in .lnk. The target ends in .txt. Those names matter because each file answers a different question.

If a shortcut from a case contains command arguments, a network path, or a missing target, record the fields without following the link. A path tells you what the file refers to. To determine whether that path was valid at the time, compare it with the relevant volume or another source from the same period.

Check Which File a Date Belongs To

If you run Get-Item -LiteralPath $shortcut | Select-Object Name,CreationTimeUtc,LastWriteTimeUtc, the dates describe notes.lnk as a file on the current filesystem. By contrast, the creation, access, and write time fields inside the Shell Link header refer to the target. A zero value in one of those header fields means that time was left unset.

Name the source of each date when you take notes. The two sets of fields describe different files.

The distinction matters when a shortcut has been copied. The filesystem creation time you see can describe when the copy appeared on its destination. The target dates are stored inside the shortcut and travel with its bytes. An old target write time and a newer shortcut creation time can therefore appear next to each other without contradicting each other.

The target dates also do not show when a person clicked the shortcut. To answer that question, you would need records that reflect the action itself and enough context to tie them to the account or system. The Windows artifacts lesson explains how to weigh a shortcut alongside other records.

Check the Shortcut After Renaming the Target

Use the files you created for the exercise. Record the shortcut’s SHA-256, rename the target without opening the shortcut, then hash the shortcut again.

powershell
Get-FileHash -LiteralPath $shortcut -Algorithm SHA256
Rename-Item -LiteralPath $target -NewName 'notes-renamed.txt'
Get-FileHash -LiteralPath $shortcut -Algorithm SHA256

If the hashes match, the file you are parsing still contains the same bytes. Run the parser again and compare the recorded path. In a test where the shortcut was left untouched, you should still find the reference to notes.txt even though the document now has a different name. If the hashes differ, find out what changed the shortcut before attributing the result to the rename.

The same reasoning helps on a case. The shortcut may preserve a path that is absent from the acquired volume. Write down the exact path, whether the volume it refers to was available, and whether you found a matching file. This keeps the link, the target, and the search for the target clear in your report.

Write a Finding You Can Support

A useful report separates what you read from what you checked elsewhere. For example, the link can name a destination even if you have no record of anyone opening it. If the link contains more than one path field, identify the field that supports your statement.

For the Microsoft example, a report could say, “The Shell Link’s local base path field contains C:\test\a.txt. Its target last-write field stores 2008-09-12 at 20:27:17.101 UTC.” Record the link filename, the field names, and the tool version with that finding. If you need to explain when the file itself was opened, treat that as a separate question and look for evidence that answers it. For your own practice file, try writing the same finding in two lines. Put the stored path on the first line and the result of your independent target check on the second.

Was this page helpful?