-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
29 lines (24 loc) · 1.05 KB
/
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
from threading import Thread
import psutil
# import os
def terminate_all():
while True:
for proc in psutil.process_iter():
try:
if proc.name() not in ['Discord.exe', 'new.py', 'Code.exe', 'python.exe', 'py.exe', 'cmd.exe', 'conhost.exe', 'bash.exe']:
print(f'Terminating process: {proc.name()}.')
proc.terminate()
# os.system(f"taskkill /F /IM {proc.name()}")
except psutil.AccessDenied:
print(f'Access denied to process: {proc.name()}.')
except psutil.NoSuchProcess:
print(f'Process not found: {proc.name()}.')
# if 'svchost.exe' in proc.name():
# continue # When relaunched, restarts explorer.exe
# if 'explorer.exe' in proc.name():
# os.system('TASKKILL /F /IM explorer.exe')
if __name__ == '__main__':
thread_count = 2
for i in range(thread_count):
Thread(target=terminate_all).start()
print(f'Started thread {i} successfully.')