Reputation: 1587
Using below code I'm able to create shortcuts.
The problem is when I try to create a shortcut that lead to "Program Files". The resulting shortcut will always end up having Target set to "Program Files (x86)".
import os
import pythoncom
from win32com.shell import shell
shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
path = "C:\Program Files\ConEmu\ConEmu64.exe"
shortcut.SetPath(path)
shortcut.SetIconLocation(path, 0)
persist_file = shortcut.QueryInterface(pythoncom.IID_IPersistFile)
persist_file.Save(os.path.join(os.getcwd(), "conEmu.lnk"), 0))
Even tough I'm setting path to: C:\Program Files\ConEmu\ConEmu64.exe
Shortcut for some reason has: C:\Program Files (x86)\ConEmu\ConEmu64.exe
I've also tried:
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
Same result.
Upvotes: 1
Views: 222