91 @type str |
92 @type str |
92 """ |
93 """ |
93 from win32com.client import Dispatch |
94 from win32com.client import Dispatch |
94 from pywintypes import com_error |
95 from pywintypes import com_error |
95 |
96 |
96 try: |
97 with contextlib.suppress(com_error): |
97 shell = Dispatch('WScript.Shell') |
98 shell = Dispatch('WScript.Shell') |
98 shortcut = shell.CreateShortCut(linkPath) |
99 shortcut = shell.CreateShortCut(linkPath) |
99 shortcut.Targetpath = targetPath |
100 shortcut.Targetpath = targetPath |
100 shortcut.WorkingDirectory = os.path.dirname(targetPath) |
101 shortcut.WorkingDirectory = os.path.dirname(targetPath) |
101 shortcut.IconLocation = iconPath |
102 shortcut.IconLocation = iconPath |
102 shortcut.save() |
103 shortcut.save() |
103 except com_error: |
|
104 # maybe restrictions prohibited link creation |
|
105 pass |
|
106 |
104 |
107 |
105 |
108 def windowsDesktopNames(): |
106 def windowsDesktopNames(): |
109 """ |
107 """ |
110 Function to generate the link names for the Windows Desktop. |
108 Function to generate the link names for the Windows Desktop. |