diff --git a/_Source/remove.py b/_Source/remove.py index e8a94b8..80a893a 100644 --- a/_Source/remove.py +++ b/_Source/remove.py @@ -83,42 +83,3 @@ else: subprocess.run(f'takeown /f "{f.path}" > NUL 2>&1', shell=True) subprocess.run(f'icacls "{f.path}" /inheritance:e /grant "{user_name}:(OI)(CI)F" /T /C > NUL 2>&1', shell=True) os.remove(f.path) - - - -## -## Disable Edge app in registry HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\ -## - # Current sser's SID - def get_current_user_sid(): - sid = ctypes.c_char_p() - size = ctypes.c_int() - ctypes.windll.advapi32.GetUserNameA(None, ctypes.byref(size)) - name = ctypes.create_string_buffer(size.value + 1) - ctypes.windll.advapi32.GetUserNameA(name, ctypes.byref(size)) - user_name = name.value.decode("utf-8") - command = f'wmic useraccount where name="{user_name}" get sid' - result = subprocess.run(command, stdout=subprocess.PIPE, shell=True).stdout.decode('utf-8') - return result.strip().split("\n")[1] - - #Find installed Edge apps - def find_edge_apps(): - command = 'Get-AppxPackage | Where-Object {$_.Name -like "*microsoftedge*"} | Select-Object PackageFullName' - result = subprocess.run(['powershell.exe', command], stdout=subprocess.PIPE).stdout.decode('utf-8') - apps = result.strip().split("\n")[1:] - return [app.strip() for app in apps if "Edge" in app] - - #Build the registry key - def add_registry_key(sid, package): - key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife") - subkey = winreg.CreateKey(key, sid) - winreg.SetValueEx(subkey, package, 0, winreg.REG_SZ, "") - winreg.CloseKey(subkey) - winreg.CloseKey(key) - - #Add the key(s) - sid = get_current_user_sid().strip() - apps = find_edge_apps() - for app in apps: - full_key = f"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Appx\\AppxAllUserStore\\EndOfLife\\{sid}\\{app}" - add_registry_key(sid, app)