-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_links.py
36 lines (30 loc) · 1.23 KB
/
create_links.py
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
29
30
31
32
33
34
35
36
from win32com.client import Dispatch
import winreg
import os
user_profile = os.environ['USERPROFILE']
desktop_registry_key = r"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
try:
# Open the Registry key
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, desktop_registry_key) as key:
# Query the Registry key to get the desktop folder path
desktop_path, _ = winreg.QueryValueEx(key, "Desktop")
desktop_path = desktop_path.replace("%USERPROFILE%", user_profile)
print("Desktop Path:", desktop_path)
except Exception as e:
print("Error:", e)
path = os.getcwd()+r"\BrightEyesMCS.lnk" #This is where the shortcut will be created
target = os.getcwd()+r"\run.bat" # directory to which the shortcut is created
icon = os.getcwd()+r"\brighteyes_mcs\images\icon.ico"
print("Creating link: ", path)
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.IconLocation = icon
shortcut.Targetpath = target
shortcut.save()
path = desktop_path+r"\BrightEyesMCS.lnk" #This is where the shortcut will be created
print("Creating link: ", path)
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.IconLocation = icon
shortcut.Targetpath = target
shortcut.save()