-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear_recycle_bin.py
More file actions
44 lines (37 loc) · 1.41 KB
/
Copy pathclear_recycle_bin.py
File metadata and controls
44 lines (37 loc) · 1.41 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
import platform
import ctypes
import json
public_description = "Clear the Windows Recycle Bin automatically."
PLATFORM = platform.system().lower()
async def function():
try:
if PLATFORM != "windows":
error_msg = f"Unsupported platform: {PLATFORM}"
print(f"Error: {error_msg}")
return json.dumps({"error": "This script only works on Windows systems"})
try:
result = ctypes.windll.shell32.SHEmptyRecycleBinW(None, None, 0)
if result == 0:
success = True
message = "Recycle bin cleared successfully!"
else:
message = f"Failed to clear recycle bin. Error code: {result}"
except Exception as e:
message = f"Error clearing recycle bin: {str(e)}"
return json.dumps({
"message": message,
"success": success
})
except Exception as e:
error_msg = f"Error in main function: {str(e)}"
print(f"\nError: {error_msg}")
return json.dumps({"error": str(e)})
object = {
"name": "clear_recycle_bin",
"description": "Clears the Windows Recycle Bin without confirmation prompts. Creates a detailed log file in the same directory. Requires administrator privileges for best results.",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
}