Skip to content

Instantly share code, notes, and snippets.

@CloudCray
Created September 9, 2014 14:15
Show Gist options
  • Save CloudCray/92c23343bf4506b03a5a to your computer and use it in GitHub Desktop.
Save CloudCray/92c23343bf4506b03a5a to your computer and use it in GitHub Desktop.
Resolve all shortcuts in the active directory
import os, sys, pythoncom
from win32com.shell import shell
def shortcut_resolves_to(shortcut_path):
shortcut = pythoncom.CoCreateInstance (
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile)
persist_file.Load (shortcut_path)
path_info = shortcut.GetPath(0)
return path_info[0]
for f in os.listdir():
if f.endswith(".lnk"):
print(f + "; " + shortcut_resolves_to(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment