I am trying to create a shortcut via python that will run the file in another program with an argument. For instance:
"C:\file.exe" "C:\folder\file.ext" argument
The code I tried fiddled with:
from win32com.client import Dispatch
import os
shell = Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = r'"C:\file.exe" "C:\folder\file.ext"'
shortcut.Arguments = argument
shortcut.WorkingDirectory = "C:\" #or "C:\folder\file.ext" in this case?
shortcut.save()
But I get an error message:
AttributeError: Property '<unknown>.Targetpath' can not be set.
I tried different line formats and google doesn't seem to know a solution to this problem.
source
share