How do I stop a Windows shortcut from updating its path?
You can use PowerShell! This little script whacks the LNK file to produce the same effect as using the classic shortcut
utility.
$linkfile = Resolve-Path $args[0]
$bytes = [IO.File]::ReadAllBytes($linkfile)
$bytes[0x16] = $bytes[0x16] -bor 0x36
[IO.File]::WriteAllBytes($linkfile, $bytes)
To use it, save that text as a .ps1
file, e.g. notrack.ps1
. If you haven't already, follow the instructions in the Enabling Scripts section of the PowerShell tag wiki. Then you can run it from a PowerShell prompt:
.\notrack.ps1 C:\path\to\my\shortcut.lnk
Shortcuts that are tweaked in this way will not change when their target moves. If a shortcut like this gets broken, nothing at all will happen when you try to open it.
I gathered the binary math used in my script from this 48-page Microsoft PDF on the LNK format.
Stop and disable the service: Distributed Link Tracking Client (TrkWks).
Distributed Link Tracking tracks links in scenarios where the link is made to a file on an NTFS volume, such as shell shortcuts. If that file is renamed, moved to another volume on the same computer, moved to another computer, or moved in other similar scenarios, Windows uses Distributed Link Tracking to find the file.
Source: Distributed Link Tracking - Microsoft Support