views:

283

answers:

1

The usual way to resolve lnk involve using WShell.WshShortcut or IShellLink that way :

var WshShell = WScript.CreateObject("WScript.Shell");
var oShellLink = WshShell.CreateShortcut(strDesktop + "\\some-shortcut.lnk");
WScript.Echo(oShellLink.TargetPath)

But there are links that can't be resolved that way : the resolution end up in c:\windows\installer\{some-guid}\python_icon.exe for example. Most Office programs have this issue too.

CodeProject has another solution done by reverse engineering the lnk format http://www.codeproject.com/KB/shell/ReadLnkFile.aspx but it does not works in thoses cases.

Is there any other way ?

What is this c:\Windows\Installer folder ? And what is this something_icon.exe that is put in it ?

+1  A: 

Ok I've found the solution here : http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/2df18f93-77d8-4217-94a1-6cbe5333a6c4

Since these lnk are MSI lnk you have to use Msi functions to resolve the path :

TCHAR pc [50] = {0};
TCHAR feat [100] = {0};
TCHAR comp [50] = {0};
int b=MsiGetShortcutTarget("Python (command line).lnk",pc,feat,comp);

TCHAR pth [500] = {0};
DWORD chs = 500;
int i = MsiGetComponentPath (pc, comp, pth, &chs);

pth contains the path.

Emmanuel Caradec