Win32 Shortcuts (.lnk files) with com in python
Class and general usage for accessing windows shortcuts in Python.
import pythoncom class Win32Shortcut: def __init__(self, lnkname): self.shortcut = pythoncom.CoCreateInstance( shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) self.shortcut.QueryInterface(pythoncom.IID_IPersistFile).Load(lnkname) def __getattr__(self, name): return getattr(self.shortcut, name) s = Win32Shortcut(path) iconPath = s.GetIconLocation()[0] itemPath = s.GetPath(0)[0]