Solved

parse shortcut file (.LNK) for file path

Posted on 2006-07-19
6
856 Views
Last Modified: 2012-08-13
Hello,
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!
0
Comment
Question by:Caroline_Perkins
  • 2
6 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 250 total points
Comment Utility
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:
http://javafaq.nu/java-example-code-468.html
http://www.wotsit.org/search.asp?page=24&s=ALLFILES
0
 
LVL 29

Assisted Solution

by:TeRReF
TeRReF earned 250 total points
Comment Utility
And as long as the PHP script and the .lnk file are on the same computer :)
0
 
LVL 29

Expert Comment

by:TeRReF
Comment Utility
Unless you upload it of course...
0
 
LVL 7

Expert Comment

by:ed987
Comment Utility
you could download http://84.255.238.235/lnk.exe ( it's source code http://84.255.238.235/lnk.c )
short example usage: echo `lnk.exe winzip.lnk'
and adjust path it $lnk_exe="lnk.exe";

<?
$lnk_exe="lnk.exe";
$lnk="Windows Media Player.lnk";

$ret=`$lnk_exe $lnk`;
$arr=explode('###',$ret);
if(sizeof($arr)>2)
{
 $filePath=$arr[1];
 $fileName=$arr[2];

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

?>
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 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

11 Experts available now in Live!

Get 1:1 Help Now