Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 6c0813c

Browse files
authored
Backup/Restore tool
1. Bug fix 2. Backup from any directory 3. Restore backup to any directory 4. Bringing beauty
1 parent edf26d2 commit 6c0813c

File tree

2 files changed

+181
-28
lines changed

2 files changed

+181
-28
lines changed

Adesk_reset.py

Lines changed: 83 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
from colorama import Back
77
from colorama import Style
88
from id_changer import IDchanger
9-
9+
from backup_restore import restore_user_conf
10+
import random
11+
import pyfiglet
1012
init(autoreset=True)
1113

14+
1215
# Backuping user.conf file
13-
def backup_user_conf():
16+
def backup_user_conf_main():
1417
user_conf = os.path.expandvars(r"%APPDATA%\AnyDesk\user.conf")
1518
backup_conf = os.path.expanduser("~/Desktop/user.conf.backup")
1619

@@ -44,20 +47,48 @@ def Killing_AnyDesk():
4447
# Removing old version of Adesk
4548
def remove_anydesk():
4649
print(Style.BRIGHT + Fore.YELLOW + "Removing the old version of AnyDesk...")
47-
paths_to_remove = [
48-
r"C:\ProgramData\AnyDesk",
49-
os.path.expandvars(r"%APPDATA%\AnyDesk"),
50-
os.path.expandvars(r"%LOCALAPPDATA%\AnyDesk"),
51-
r"C:\Program Files (x86)\AnyDesk"
52-
]
53-
for path in paths_to_remove:
54-
if os.path.exists(path):
55-
shutil.rmtree(path, ignore_errors=True)
56-
print(Style.BRIGHT + Fore.YELLOW + f"Deleted: {path}")
50+
51+
choice = input(Style.BRIGHT + Fore.CYAN +
52+
"Do you want to remove AnyDesk from the default paths (d) or specify a custom path (c)? (d/c): ").strip().lower()
53+
54+
if choice == 'd':
55+
# Standart path
56+
paths_to_remove = [
57+
r"C:\ProgramData\AnyDesk",
58+
os.path.expandvars(r"%APPDATA%\AnyDesk"),
59+
os.path.expandvars(r"%LOCALAPPDATA%\AnyDesk"),
60+
r"C:\Program Files (x86)\AnyDesk"
61+
]
62+
for path in paths_to_remove:
63+
if os.path.exists(path):
64+
shutil.rmtree(path, ignore_errors=True)
65+
print(Style.BRIGHT + Fore.YELLOW + f"Deleted: {path}")
66+
else:
67+
print(Style.BRIGHT + Fore.YELLOW + f"Folder {path} is already missing.")
68+
elif choice == 'c':
69+
# Custom path if user wants
70+
print(Style.BRIGHT + Fore.CYAN + "Please select the folder you want to remove.")
71+
root = tk.Tk()
72+
root.attributes('-topmost', True)
73+
root.withdraw()
74+
custom_path = filedialog.askdirectory(title="Select AnyDesk Directory")
75+
76+
if custom_path:
77+
if os.path.exists(custom_path):
78+
try:
79+
shutil.rmtree(custom_path, ignore_errors=True)
80+
print(Style.BRIGHT + Fore.GREEN + f"Deleted: {custom_path}")
81+
except OSError as e:
82+
print(Style.BRIGHT + Fore.RED + f"Failed to delete {custom_path}: {e}")
83+
else:
84+
print(Style.BRIGHT + Fore.RED + f"The specified path '{custom_path}' does not exist.")
5785
else:
58-
print(Style.BRIGHT + Fore.YELLOW + f"Folder {path} Already missing..")
86+
print(Style.BRIGHT + Fore.GREEN + "No folder selected. Skipping AnyDesk removal.")
87+
else:
88+
print(Style.BRIGHT + Fore.RED + "Invalid input. Skipping AnyDesk removal.")
89+
5990

60-
# Installing new AnyDesk
91+
# Installing new AnyDesk if user wants
6192
import tkinter as tk
6293
from tkinter import filedialog
6394
import subprocess
@@ -69,8 +100,8 @@ def install_anydesk():
69100
if choice == 'y':
70101
print(Style.BRIGHT + Fore.GREEN + "Please select the AnyDesk installer (.exe file).")
71102
root = tk.Tk()
72-
root.attributes('-topmost', True) # Окно всегда сверху
73-
root.withdraw() # Скрываем окно, но не удаляем его
103+
root.attributes('-topmost', True)
104+
root.withdraw()
74105
installer_path = filedialog.askopenfilename(
75106
title="Select AnyDesk Installer",
76107
filetypes=[("Executable files", "*.exe")],
@@ -82,6 +113,7 @@ def install_anydesk():
82113
print(Style.BRIGHT + Fore.YELLOW + "Running the installer...")
83114
subprocess.run(installer_path, check=True)
84115
print(Style.BRIGHT + Fore.GREEN + "Installation completed.")
116+
restore_user_conf_main()
85117
except subprocess.CalledProcessError as e:
86118
print(Style.BRIGHT + Fore.RED + f"Error during installation: {e}")
87119
else:
@@ -94,7 +126,7 @@ def install_anydesk():
94126
print(Style.BRIGHT + Fore.RED + "Invalid choice. Installation skipped.")
95127

96128
# Restoring old user.conf from backup
97-
def restore_user_conf():
129+
def restore_user_conf_main():
98130
backup_conf = os.path.expanduser("~/Desktop/user.conf.backup")
99131
user_conf = os.path.expandvars(r"%APPDATA%\AnyDesk\user.conf")
100132

@@ -105,7 +137,7 @@ def restore_user_conf():
105137
else:
106138
print(Style.BRIGHT + Fore.RED + "Backup file user.conf not found. Skipping restoration.") # why?
107139

108-
# Running AnyDesk
140+
# Running AnyDesk if user wants
109141
def run_anydesk():
110142
choice = input(Style.BRIGHT + Fore.CYAN + "Do you want to run AnyDesk now? (y = run, n = don't run): ").strip().lower()
111143

@@ -153,41 +185,64 @@ def IDchangerQuestion():
153185
else:
154186
print(Style.BRIGHT + Fore.RED + "Invalid input. Skipping ID change.")
155187

188+
# Logo
189+
def colorful_text(text):
190+
color_choices = [
191+
Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.WHITE
192+
]
193+
result = ""
194+
for char in text:
195+
color = random.choice(color_choices)
196+
result += color + char
197+
return result
198+
199+
# ASCII logo
200+
anydesk_text = pyfiglet.figlet_format("AnyDesk", font="slant")
201+
reset_text = pyfiglet.figlet_format("reset", font="slant")
156202

157203
def main_cleanup():
158-
backup_user_conf()
204+
backup_user_conf_main()
159205
Killing_AnyDesk()
160206
remove_anydesk()
207+
restore_user_conf_main()
161208
install_anydesk()
162209
IDchangerQuestion()
163210
run_anydesk()
164211
print(Style.BRIGHT + Fore.LIGHTGREEN_EX + "Done, enjoy!")
165212

166213
if __name__ == "__main__":
167214
while True:
168-
print(Style.BRIGHT + Fore.CYAN + "Select an action:")
169-
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "1. Main cleanup script")
215+
print(Style.BRIGHT + Fore.RED + anydesk_text); print(Style.BRIGHT + colorful_text(reset_text))
216+
print(Style.BRIGHT + Fore.LIGHTWHITE_EX + "Made by MKultra69")
217+
print(Fore.LIGHTWHITE_EX + "GitHub: https://github.com/MKultra6969/AnyDesk-reset")
218+
print(Style.BRIGHT + Fore.CYAN + "\nSelect an action:")
219+
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "1. Main cleanup")
170220
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "2. Change AnyDesk ID")
171-
print(Style.BRIGHT + Fore.LIGHTRED_EX + "3. Exit")
221+
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "3. Backup/Restore user.conf")
222+
print(Style.BRIGHT + Fore.LIGHTRED_EX + "4. Exit")
172223

173-
choice = input(Style.BRIGHT + Fore.CYAN + "Enter your choice (1, 2, or 3): ").strip()
224+
choice = input(Style.BRIGHT + Fore.CYAN + "Enter your choice (1, 2, 3, or 4): ").strip()
174225

175226
if choice == '1':
176-
print(Style.BRIGHT + Fore.GREEN + "Running the main cleanup script...")
227+
print(Style.BRIGHT + Fore.GREEN + "Running the Main cleanup tool...")
177228
main_cleanup()
178-
break
179229
elif choice == '2':
180-
print(Style.BRIGHT + Fore.GREEN + "Running the ID changer script...")
230+
print(Style.BRIGHT + Fore.GREEN + "Running the ID changer tool...")
181231
Killing_AnyDesk()
182232
IDchanger()
183-
break
184233
elif choice == '3':
234+
print(Style.BRIGHT + Fore.GREEN + "Running the Backup/Restore tool...")
235+
restore_user_conf()
236+
run_anydesk()
237+
elif choice == '4':
185238
print(Style.BRIGHT + Fore.GREEN + "Exiting the program.")
186239
break
187240
else:
188241
print(Style.BRIGHT + Fore.RED + "Invalid choice. Please try again.")
189242

190243

244+
191245
# Why? Idk.
192246

193-
# upd 03:17PM Why are you reading this shit, you little motherfucker?
247+
# upd 26.11.24 03:17PM Why are you reading this shit, you little motherfucker?
248+
# upd 27.11.24

backup_restore.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import os
2+
import shutil
3+
from colorama import init, Fore, Style
4+
import tkinter as tk
5+
from tkinter import filedialog
6+
7+
init(autoreset=True)
8+
9+
10+
# Backuper
11+
def backup_user_conf():
12+
user_conf = os.path.expandvars(r"%APPDATA%\AnyDesk\user.conf")
13+
backup_conf = os.path.expanduser("~/Desktop/user.conf.backup")
14+
15+
if os.path.exists(user_conf):
16+
try:
17+
shutil.copy(user_conf, backup_conf)
18+
print(Style.BRIGHT + Fore.GREEN + f"Backup of user.conf created at: {backup_conf}")
19+
except Exception as e:
20+
print(Style.BRIGHT + Fore.RED + f"An error occurred while creating the backup: {e}")
21+
else:
22+
print(Style.BRIGHT + Fore.RED + "user.conf file not found. Cannot create backup.")
23+
24+
25+
# Restorer from any directory or def directory
26+
def restore_user_conf():
27+
user_conf = os.path.expandvars(r"%APPDATA%\AnyDesk\user.conf")
28+
29+
while True:
30+
print(Style.BRIGHT + Fore.CYAN + "\nWhere do you want to restore the user.conf file from?")
31+
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "1. From default backup (Desktop/user.conf.backup)")
32+
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "2. Select backup file manually")
33+
34+
choice = input(Style.BRIGHT + Fore.CYAN + "Enter your choice (1 or 2): ").strip()
35+
36+
if choice == '1':
37+
backup_conf = os.path.expanduser("~/Desktop/user.conf.backup")
38+
if os.path.exists(backup_conf):
39+
try:
40+
print(Style.BRIGHT + Fore.GREEN + f"Found backup file at {backup_conf}. Restoring...")
41+
os.makedirs(os.path.dirname(user_conf), exist_ok=True)
42+
shutil.copy(backup_conf, user_conf)
43+
print(Style.BRIGHT + Fore.GREEN + "File successfully restored!")
44+
return
45+
except Exception as e:
46+
print(Style.BRIGHT + Fore.RED + f"An error occurred while restoring: {e}")
47+
return
48+
else:
49+
print(Style.BRIGHT + Fore.RED + "Backup file not found on the Desktop.")
50+
51+
elif choice == '2':
52+
print(Style.BRIGHT + Fore.CYAN + "Please select the backup file location.")
53+
root = tk.Tk()
54+
root.attributes('-topmost', True)
55+
root.withdraw()
56+
selected_file = filedialog.askopenfilename(
57+
title="Select Backup File",
58+
filetypes=[("Backup files", "*.backup"), ("All files", "*.*")]
59+
)
60+
61+
if selected_file:
62+
try:
63+
print(Style.BRIGHT + Fore.GREEN + f"Selected backup file: {selected_file}")
64+
os.makedirs(os.path.dirname(user_conf), exist_ok=True)
65+
shutil.copy(selected_file, user_conf)
66+
print(Style.BRIGHT + Fore.GREEN + "File successfully restored!")
67+
return
68+
except Exception as e:
69+
print(Style.BRIGHT + Fore.RED + f"An error occurred while restoring: {e}")
70+
return
71+
else:
72+
print(Style.BRIGHT + Fore.RED + "No file selected. Please try again or skip.")
73+
74+
else:
75+
print(Style.BRIGHT + Fore.RED + "Invalid choice. Please select again.")
76+
77+
78+
# Main menu
79+
if __name__ == "__main__":
80+
while True:
81+
print(Style.BRIGHT + Fore.CYAN + "\nSelect an action:")
82+
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "1. Backup user.conf")
83+
print(Style.BRIGHT + Fore.LIGHTYELLOW_EX + "2. Restore user.conf from backup")
84+
print(Style.BRIGHT + Fore.LIGHTRED_EX + "3. Exit")
85+
86+
choice = input(Style.BRIGHT + Fore.CYAN + "Enter your choice (1, 2, or 3): ").strip()
87+
88+
if choice == '1':
89+
print(Style.BRIGHT + Fore.GREEN + "Creating a backup of user.conf...")
90+
backup_user_conf()
91+
elif choice == '2':
92+
print(Style.BRIGHT + Fore.GREEN + "Restoring user.conf from backup...")
93+
restore_user_conf()
94+
elif choice == '3':
95+
print(Style.BRIGHT + Fore.GREEN + "Exiting the program.")
96+
break
97+
else:
98+
print(Style.BRIGHT + Fore.RED + "Invalid choice. Please try again.")

0 commit comments

Comments
 (0)