Home All Groups Group Topic Archive Search About
Author
14 Apr 2010 2:05 AM
Fred
Hi,

Given a shortcut file (*.lnk) I need to find it's Target address.
Can some please help me out.

Thanks,
Fred

Author
14 Apr 2010 12:46 PM
Herfried K. Wagner [MVP]
Am 14.04.2010 04:05, schrieb Fred:
> Given a shortcut file (*.lnk) I need to find it's Target address. Can
> some please help me out.

Samples
<URL:http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp>

--
  M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
14 Apr 2010 7:43 PM
Onur_Güzel
On Apr 14, 5:05 am, "Fred" <repl...@newsgroup.please> wrote:
> Hi,
>
> Given a shortcut file (*.lnk) I need to find it's Target address.
> Can some please help me out.
>
> Thanks,
> Fred

Add a reference to "Windows Script Host Object Model" through COM tab
in "Add Reference" dialog.

Then pass the necessary .lnk location to find its target path as
follows:

'-------------------------
Start------------------------------------------------------
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType((New IWshRuntimeLibrary.WshShell).CreateShortcut _
("c:\shortcut_here.lnk"), _
IWshRuntimeLibrary.IWshShortcut)

' Get target path in messagebox
MsgBox(shortCut.TargetPath)
'-------------------------
End------------------------------------------------------

HTH,

Onur Güzel
Author
14 Apr 2010 8:38 PM
Fred
Thanks Onur and Herfried.


Show quoteHide quote
"Onur Güzel" <kimiraikkone***@gmail.com> wrote in message
news:142c029e-34f4-43fd-8abe-c44770de57c6@c36g2000yqm.googlegroups.com...
> On Apr 14, 5:05 am, "Fred" <repl...@newsgroup.please> wrote:
>> Hi,
>>
>> Given a shortcut file (*.lnk) I need to find it's Target address.
>> Can some please help me out.
>>
>> Thanks,
>> Fred
>
> Add a reference to "Windows Script Host Object Model" through COM tab
> in "Add Reference" dialog.
>
> Then pass the necessary .lnk location to find its target path as
> follows:
>
> '-------------------------
> Start------------------------------------------------------
> Dim shortCut As IWshRuntimeLibrary.IWshShortcut
> shortCut = CType((New IWshRuntimeLibrary.WshShell).CreateShortcut _
> ("c:\shortcut_here.lnk"), _
> IWshRuntimeLibrary.IWshShortcut)
>
> ' Get target path in messagebox
> MsgBox(shortCut.TargetPath)
> '-------------------------
> End------------------------------------------------------
>
> HTH,
>
> Onur Güzel