Unable To Launch Windows Shortcut
I'm trying to launch a windows with python. I've tried NUMEROUS approaches with os.system, subprocess.call, os.startfile etc. but I'm always getting an error saying that the path d
Solution 1:
According to this answer, you could resolve your link path, then call the resolved path
import sys
import win32com.client,win32api
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(r"D:\johan\programmering\Scripts\shortcuts\HWMonitor.lnk")
long_path = shortcut.Targetpath
but long_path
may be a strange Windows path with a lot of junk in it, so if
subprocess.call([long_path])
doesn't work, you can resolve the long path in a short path (8.3 names):
short_path=win32api.GetShortPathName(long_path)
now do:
subprocess.call([short_path])
Post a Comment for "Unable To Launch Windows Shortcut"