-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.py
46 lines (36 loc) · 1.2 KB
/
installer.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
37
38
39
40
41
42
43
44
45
46
from ast import arguments
from shutil import copyfile
import os
import sys
locate_python = sys.exec_prefix
os.system('{}\\python -m pip install -r requirements.txt'.format(locate_python))
os.system('{}\\python -m pipwin install pywin32'.format(locate_python))
os.system('{}\\python -m pip install -U pystray --no-cache-dir'.format(locate_python))
from win32com.client import Dispatch
working_directory = 'C:\\Users\\{}\\AppData\\Roaming\\Alive'.format(
os.getlogin())
start_directory = 'C:\\Users\\{}\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\'.format(
os.getlogin())
tray_file = 'tray.py'
# Create Folders
try:
os.mkdir(working_directory)
except:
pass
try:
tray_path = "{}\\{}".format(working_directory, tray_file)
icon_path = "{}\\Alive.ico".format(working_directory)
copyfile(tray_file, tray_path)
copyfile('Alive.ico', icon_path)
except:
pass
path = os.path.join(start_directory, 'Alive.lnk')
target = "{}\\pythonw".format(locate_python)
t_arguments = tray_path
icon = icon_path
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.TargetPath = target
shortcut.Arguments = t_arguments
shortcut.IconLocation = icon
shortcut.save()