-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (52 loc) · 2.07 KB
/
main.py
File metadata and controls
65 lines (52 loc) · 2.07 KB
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
import traceback, os, getpass
from threading import Thread
print("Please confirm account deletion Y/N :")
user_response = input()
def start_deletion():
if user_response == "Y" or user_response == "y":
try:
current_user = getpass.getuser()
print(current_user)
# set the directory path to C:\Users
user_dir = "C:\\Users\\"
# list all directories in the user directory
directories = os.listdir(user_dir)
# loop through the directories and delete only the ones that are not default and not the current user's directory
for directory in directories:
if (
directory
not in [
"Default",
"Public",
"All Users",
"Default User",
"desktop.ini",
"Administrator",
"TEMP",
"Admin",
"Temp",
]
and directory != current_user
):
dir_path = os.path.join(user_dir, directory)
try:
# delete the directory and all its contents recursively
os.system('rmdir /S /Q "{}"'.format(dir_path))
print("Directory '{}' deleted successfully.".format(directory))
except Exception as e:
print(
"Failed to delete directory '{}'. Error: {}".format(
dir_path, e
)
)
print(
"All user profiles except the current and system profiles have been deleted."
)
except:
print(str(traceback.format_exc()))
except:
print("ads")
x = Thread(target=start_deletion)
x.start()
x.join()
input("Press Enter to continue...")