Get a shortcut target path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

My question seens very simple: i want to write a function like
private string ResolveLink(string LinkFilePath) { ... }
that receives, for example, "c:\\myshortcut.lnk" and gives back the
shortcut's target path. Just the target's path.

Tks!
 
Found the solution:

Add the COM reference: Windows Script Host Object Model

Code:

using IWshRuntimeLibrary;

private string Resolve(string LnkFilePath)
{
WshShell shell = new WshShellClass();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(LnkFilePath);
return link.TargetPath;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top