1+
2+ #
3+ # This project would not be possible without the support of these awesome people
4+ # https://github.com/ShadowWhisperer/Remove-MS-Edge/graphs/contributors
5+ #
6+
17import ctypes # Check if ran as an admin / Window title
28import getpass # Take Permissions
39import os # System OS paths
1521 sys .exit (1 )
1622
1723# Title
18- ctypes .windll .kernel32 .SetConsoleTitleW ("Bye Bye Edge - 8/12/2025 - ShadowWhisperer" )
24+ ctypes .windll .kernel32 .SetConsoleTitleW ("Bye Bye Edge - 2.3 - ShadowWhisperer" )
1925
2026# Hide CMD/Powershell
2127def hide_console ():
@@ -44,19 +50,22 @@ def hide_console():
4450################################################################################################################################################
4551
4652# Edge
47- EDGE_PATH = os .path .join (PROGRAM_FILES_X86 , "Microsoft\\ Edge\\ Application\\ pwahelper.exe" )
48- if os .path .exists (EDGE_PATH ):
49- print ("Removing Microsoft Edge" )
50- cmd = [src , "--uninstall" , "--system-level" , "--force-uninstall" ]
51- subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = subprocess .DEVNULL , text = True )
52- os .system ("timeout /t 2 >nul" )
53+ for p in [os .path .join (PROGRAM_FILES_X86 , "Microsoft\\ Edge\\ Application\\ pwahelper.exe" ), os .path .join (PROGRAM_FILES , "Microsoft\\ Edge\\ Application\\ pwahelper.exe" )]:
54+ if os .path .exists (p ):
55+ print ("Removing Microsoft Edge" )
56+ cmd = [src , "--uninstall" , "--system-level" , "--force-uninstall" ]
57+ subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = subprocess .DEVNULL , text = True )
58+ os .system ("timeout /t 2 >nul" )
59+ break
5360
5461# WebView
55- EDGE_PATH = os .path .join (PROGRAM_FILES_X86 , "Microsoft\\ EdgeWebView\\ Application" )
56- if os .path .exists (EDGE_PATH ):
57- print ("Removing WebView" )
58- cmd = [src , "--uninstall" , "--msedgewebview" , "--system-level" , "--force-uninstall" ]
59- subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = subprocess .DEVNULL , text = True )
62+ for p in [os .path .join (PROGRAM_FILES_X86 , "Microsoft\\ EdgeWebView\\ Application" ), os .path .join (PROGRAM_FILES , "Microsoft\\ EdgeWebView\\ Application" )]:
63+ if os .path .exists (p ):
64+ print ("Removing Microsoft WebView" )
65+ cmd = [src , "--uninstall" , "--msedgewebview" , "--system-level" , "--force-uninstall" ]
66+ subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = subprocess .DEVNULL , text = True )
67+ os .system ("timeout /t 2 >nul" )
68+ break
6069
6170# Edge / MicrosoftEdgeDevTools (Appx Packages)
6271user_sid = subprocess .check_output (["powershell" , "(New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value" ], startupinfo = hide_console ()).decode ().strip ()
@@ -65,41 +74,7 @@ def hide_console():
6574base_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore"
6675for app in edge_apps :
6776 for path in [f"{ base_path } \\ EndOfLife\\ { user_sid } \\ { app } " , f"{ base_path } \\ EndOfLife\\ S-1-5-18\\ { app } " , f"{ base_path } \\ Deprovisioned\\ { app } " ]:
68- winreg .CreateKeyEx (winreg .HKEY_LOCAL_MACHINE , path , 0 , access = access_flag )
69-
70-
71- ################################################################################################################################################
72-
73- # Delete bad reg keys - https://github.com/ShadowWhisperer/Remove-MS-Edge/issues/80
74- def should_delete (name ):
75- return not re .search (r'[a-zA-Z]' , name ) or ' ' in name
76-
77- def delete_tree (root , path ):
78- try :
79- with winreg .OpenKey (root , path , 0 , winreg .KEY_ALL_ACCESS | access_flag ) as key :
80- while True :
81- try :
82- delete_tree (root , f"{ path } \\ { winreg .EnumKey (key , 0 )} " )
83- except OSError :
84- break
85- winreg .DeleteKeyEx (root , path , access = access_flag )
86- except :
87- pass
88-
89- def clean_subkeys (root , path ):
90- try :
91- with winreg .OpenKey (root , path , 0 , winreg .KEY_ALL_ACCESS | access_flag ) as key :
92- for i in range (winreg .QueryInfoKey (key )[0 ]):
93- subkey = winreg .EnumKey (key , i )
94- subkey_path = f"{ path } \\ { subkey } "
95- if should_delete (subkey ):
96- delete_tree (root , subkey_path )
97- else :
98- clean_subkeys (root , subkey_path )
99- except :
100- pass
101-
102- clean_subkeys (winreg .HKEY_LOCAL_MACHINE , "SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Appx\\ AppxAllUserStore" )
77+ winreg .CreateKeyEx (winreg .HKEY_LOCAL_MACHINE , path , 0 , access_flag )
10378
10479################################################################################################################################################
10580
@@ -165,6 +140,7 @@ def remove_directory(path):
165140
166141 run_cmd (["taskkill" , "/IM" , "MicrosoftEdgeUpdate.exe" , "/F" ])
167142 for folder in ["Edge" , "EdgeCore" , "EdgeUpdate" , "Temp" ]:
143+ remove_directory (os .path .join (PROGRAM_FILES , "Microsoft" , folder ))
168144 remove_directory (os .path .join (PROGRAM_FILES_X86 , "Microsoft" , folder ))
169145
170146# Files - System32
@@ -183,26 +159,28 @@ def remove_directory(path):
183159# Denied
184160##############
185161# AppUserModelId
162+ # Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Families
163+ # Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages
164+ # Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Families
186165# SOFTWARE\Microsoft\Windows\CurrentVersion\AppModel\StateRepository\Cache\Package\Index\PackageFullName
187166# SOFTWARE\Microsoft\WindowsRuntime\ActivatableClassId
188- # Software\Microsoft\\Windows\\CurrentVersion\\AppModel\Repository\Families
189- # Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages
167+
190168
191169def delete_keys (hive , key , access ):
192170 try :
193171 with winreg .OpenKey (hive , key , 0 , access | winreg .KEY_READ ) as k :
172+ subkeys = []
173+ i = 0
194174 while True :
195175 try :
196- subkey = winreg .EnumKey (k , 0 )
197- delete_keys ( hive , f" { key } \\ { subkey } " , access )
176+ subkeys . append ( winreg .EnumKey (k , i ) )
177+ i += 1
198178 except OSError :
199179 break
180+ for subkey in subkeys :
181+ delete_keys (hive , f"{ key } \\ { subkey } " , access )
200182 winreg .DeleteKeyEx (hive , key , access )
201- except FileNotFoundError :
202- pass
203- except PermissionError :
204- pass
205- except Exception as e :
183+ except :
206184 pass
207185
208186def delete_subkeys_with_prefix (hive , path , prefix , access ):
@@ -318,7 +296,7 @@ def delete_hkcr_microsoftedge_keys():
318296 try :
319297 key_name = winreg .EnumKey (root , i )
320298 if key_name .startswith (("MicrosoftEdge" , "microsoft-edge" )):
321- delete_keys (hive , f"{ base_path } \\ { key_name } " , access | winreg . KEY_ALL_ACCESS )
299+ delete_keys (hive , f"{ base_path } \\ { key_name } " , access )
322300 else :
323301 i += 1
324302 except OSError :
0 commit comments