slloyd has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to programatically read the information from a windows shortcut file? I noticed that they are .lnk fils. In particular, I am interested in the Target and Start in values.
Update: I think I found the answer.. Win32::Shortcut.

http://www.basgetti.com

Replies are listed 'Best First'.
Re: Reading windows shortcut files
by PerlingTheUK (Hermit) on Jun 12, 2005 at 08:04 UTC
    I have never used this extensively but this pdf tells you how they are fromatted. A little unpack-ing should help you do the job.

    Cheers,
    PerlingTheUK
Re: Reading windows shortcut files
by kaif (Friar) on Jun 13, 2005 at 02:25 UTC

    You seem to have already found the appropriate module: Win32::Shortcut.

    For others reading this discussion, and for future reference, Perl in a Nutshell has a small section on this module. At least for the moment, this is available online for free on Safari Bookshelf. As of the second edition, the appropriate section is 22.18, with the entire 22nd chapter of the book being on Win32.

    From the book above, I learned that the following code will print the Target and Start In values you wanted:

    $link = new Win32::Shortcut(); $link->Load("test.lnk"); print "Target: $link->{Path} $link->{Arguments}\n"; print "Start In: $link->{WorkingDirectory}\n";