-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwin_autostart.py
31 lines (26 loc) · 1.05 KB
/
win_autostart.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
from sys import platform # For detecting OS
import os
# Checks for Windows OS(both 32 & 64 bit)
if platform == "win32":
# generate battery_alert.bat script
dir_path = os.path.dirname(os.path.realpath(__file__))
py_abs_path = '"' + os.path.join(dir_path, 'battery_alert.py') + '"\n'
script = "python " + py_abs_path
# Creating the .bat file
bat_path = os.path.join(dir_path, 'win_autostart.bat')
with open(bat_path, 'w') as fp:
fp.write("@echo off\n")
fp.write(script)
fp.write("@pause\n")
# Creating the .vbs file
vbs_path = os.path.join(dir_path, 'battery_alert.vbs')
with open(vbs_path, 'w') as fp:
temp = 'CreateObject("Wscript.Shell").Run "win_autostart.bat", 0, True'
fp.write(temp)
print('Operation Completed Successfully...')
# Check for Linux OS
elif platform.startswith("linux"):
print('Linux OS is detected.\nThis code is only for Windows OS.')
# Check for MAC OS
elif platform == "darwin":
print('Mac OS is detected.\nThis code is only for Windows OS.')