-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_desktop_shortcut.py
More file actions
28 lines (22 loc) · 947 Bytes
/
create_desktop_shortcut.py
File metadata and controls
28 lines (22 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os, winshell
from win32com.client import Dispatch
# Providing paths and other variables
desktop = winshell.desktop()
path = os.path.join(desktop, "Pairs Game.lnk")
target = r"C:\Games\Pairs-Game-Python\StartGame.bat"
wDir = r"C:\Games\Pairs-Game-Python"
icon = r"C:\Games\Pairs-Game-Python\assets\images\enally.ico"
# Runs WScript.Shell using on windows to execute commands
shell = Dispatch('WScript.Shell')
# Data to be added on shortcut file.
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
# About Winshell
# The winshell module is a light wrapper around the Windows shell functionality.
# It includes convenience functions for accessing special folders, for using the shell’s file copy, rename &
# delete functionality, and a certain amount of support for structured storage.
#About Dispatch
# Is event handlerfor Python (runtime)