-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
48 lines (34 loc) · 1012 Bytes
/
main.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
47
48
import time
from watchdog.observers import Observer
import ctypes, sys
import Scanner
import os
WatcherPath = os.path.join(os.path.join(os.environ['USERPROFILE']))
class Watcher:
def __init__(self, path):
self.observer = Observer()
self.path = path
def run(self):
event_handler = Scanner.Handler()
self.observer.schedule(event_handler, self.path, recursive=True)
self.observer.start()
self.observer.join()
try:
while True:
time.sleep(1)
except:
self.observer.stop()
print("Error")
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if __name__ == "__main__":
Scanner.Handler()
if is_admin():
w = Watcher(WatcherPath)
w.run()
else:
print("admin")
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)