parse shortcut file (.LNK) for file path

Posted on 2006-07-19
Last Modified: 2012-08-13
Is it possible to parse a Windows .lnk file and retrieve the file path that it points to?
I can do it in Javascript and wondering if it's possible in PHP.

Thanks for your help!
Question by:Caroline_Perkins
  • 2
LVL 33

Accepted Solution

snoyes_jw earned 250 total points
ID: 17141845
Sure, it's possible. I don't know of a ready-made solution in PHP, but it should be relatively simple to translate one of the following version from Java or C:
LVL 29

Assisted Solution

TeRReF earned 250 total points
ID: 17141970
And as long as the PHP script and the .lnk file are on the same computer :)
LVL 29

Expert Comment

ID: 17141972
Unless you upload it of course...

Expert Comment

ID: 17145641
you could download ( it's source code )
short example usage: echo `lnk.exe winzip.lnk'
and adjust path it $lnk_exe="lnk.exe";

$lnk="Windows Media Player.lnk";

$ret=`$lnk_exe $lnk`;

 echo "FilePath = $filePath";
 echo "FileName = $fileName";
else echo "Error reading lnk ($ret)";


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question