Answer the question
In order to leave comments, you need to log in
How to create a shortcut for an application?
I need to create a shortcut for the selected file to the selected location
Answer the question
In order to leave comments, you need to log in
On Windows, you can create a shortcut using the pywin32 library:
import pythoncom
import os
# pythoncom.CoInitialize() # remove the '#' at the beginning of the line if running in a thread.
desktop = r'C:\Users\Public\Desktop' # path to where you want to put the .lnk
path = os.path.join(desktop, 'NameOfShortcut.lnk')
target = r'C:\path\to\target\file.exe'
icon = r'C:\path\to\icon\resource.ico' # not needed, but nice
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.IconLocation = icon
shortcut.WindowStyle = 7 # 7 - Minimized, 3 - Maximized, 1 - Normal
shortcut.save()
from swinlnk.swinlnk import SWinLnk
swl = SWinLnk()
swl.create_lnk('W:\Foo\Bar', '/mnt/win_share/playground/Bar_winlink.lnk')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question