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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now