-
Notifications
You must be signed in to change notification settings - Fork 2
/
uninstaller.py
75 lines (58 loc) · 1.97 KB
/
uninstaller.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import sys
import winreg
import json
import shutil
import time
import ctypes
import subprocess
ctypes.windll.kernel32.SetConsoleTitleW('GD Localisation Uninstaller')
REG_PATH = 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\GDLoc'
EXPLORER_PATH = os.path.join(os.getenv('WINDIR'), 'explorer.exe')
input('Нажмите ENTER, чтобы удалить GDL (Press ENTER to remove GDL): ')
def explore(path):
path = os.path.normpath(path)
if os.path.isdir(path):
subprocess.run([EXPLORER_PATH, path])
elif os.path.isfile(path):
subprocess.run([EXPLORER_PATH, '/select,', path])
def clear_temp():
for j in os.listdir(os.environ['TEMP']):
path = os.path.join(os.environ['TEMP'], j)
if not os.path.isdir(path):
continue
if not j.startswith('_MEI'):
continue
try:
shutil.rmtree(path)
except Exception as er:
print(f'Not fully cleared: {er}')
try:
reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
key = winreg.OpenKey(reg, REG_PATH, 0, winreg.KEY_READ)
os.chdir(os.path.dirname(winreg.QueryValueEx(key, 'UninstallString')[0].replace('"', '')))
winreg.DeleteKeyEx(winreg.HKEY_LOCAL_MACHINE, REG_PATH)
except Exception as e:
print(f'Error clearing regedit: {e}')
temp_file = open('gdl_unins000.txt', 'rb')
backup = json.loads(temp_file.read().decode())
temp_file.close()
for i in backup:
if not os.access(i, os.F_OK) or not os.access(backup[i], os.F_OK):
continue
try:
os.remove(i)
except Exception as e:
print(f'Error removing backup: {e}')
try:
os.rename(backup[i], i)
except Exception as e:
print(f'Error renaming backup: {e}')
try:
os.remove('gdl_unins000.txt')
except Exception as e:
print(f'Error removing file: {e}')
print('Данный файл удалите вручную... (Remove this file manually...)')
time.sleep(3)
explore(sys.executable)
clear_temp()