Creating a file shortcut (.lnk)

One way to do this is pointed out by Joepro in their answer here: You’ll need to add a COM reference to Windows Scripting Host. As far as i know, there is no native .net way to do this. WshShellClass wsh = new WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut( Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + “\\shorcut.lnk”) as IWshRuntimeLibrary.IWshShortcut; shortcut.Arguments = … Read more

Reading the target of a .lnk file in Python?

Create a shortcut using Python (via WSH) import sys import win32com.client shell = win32com.client.Dispatch(“WScript.Shell”) shortcut = shell.CreateShortCut(“t:\\test.lnk”) shortcut.Targetpath = “t:\\ftemp” shortcut.save() Read the Target of a Shortcut using Python (via WSH) import sys import win32com.client shell = win32com.client.Dispatch(“WScript.Shell”) shortcut = shell.CreateShortCut(“t:\\test.lnk”) print(shortcut.Targetpath)