-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunning.py
More file actions
24 lines (21 loc) · 1.06 KB
/
Copy pathrunning.py
File metadata and controls
24 lines (21 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import win32com.client
#Call this function to add the application to the startup folder
def add_to_startup():
app_path = os.path.dirname(__file__)
startup_folder = os.path.join(os.environ['APPDATA'], 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup')
shortcut_path = os.path.join(startup_folder, 'ReConnect.lnk')
# Create a shortcut to the application executable
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortcut(shortcut_path)
shortcut.TargetPath = os.path.join(app_path, 'ReConnect.bat')
shortcut.WorkingDirectory = app_path
shortcut.Description = 'Your App'
shortcut.IconLocation = os.path.join(app_path, 'your_app.ico')
shortcut.save()
#Call this function to remove the application from the startup folder
def remove_from_startup():
startup_folder = os.path.join(os.environ['APPDATA'], 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup')
shortcut_path = os.path.join(startup_folder, 'ReConnect.lnk')
if os.path.exists(shortcut_path):
os.remove(shortcut_path)