Advertisement
Python253

uninstall_edge_no_updates

Mar 18th, 2024
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.91 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Filename: uninstall_edge_no_updates.py
  3. # Version: 1.00
  4. # Author: Jeoi Reqi
  5.  
  6. """
  7. Description:
  8. This script uninstalls Microsoft Edge Spyware Browser from Windows 10 and prevents it from being automatically reinstalled.
  9. It retrieves the Edge version number automatically, uninstalls Edge Spyware using Command Prompt, and prevents Edge reinstall by modifying the registry.
  10.  
  11. Requirements:
  12. - Windows 10
  13. - Python 3.x
  14.  
  15. Usage:
  16. 1. Make sure you have Python installed on your Windows machine.
  17. 2. Run the script by executing `python uninstall_edge.py` in Command Prompt or PowerShell with administrator privileges.
  18. """
  19.  
  20. import os
  21. import subprocess
  22. import winreg
  23.  
  24. # Function to get the version
  25. def get_edge_version():
  26.     """
  27.    Retrieve the version number of Microsoft Edge Spyware installed on the system.
  28.    
  29.    Returns:
  30.    - str: The version number of Microsoft Edge Spyware if found, otherwise None.
  31.    """
  32.     # Get Edge version from the application folder
  33.     edge_path = os.path.join(os.getenv("ProgramFiles(x86)"), "Microsoft", "Edge", "Application")
  34.     versions = [d for d in os.listdir(edge_path) if os.path.isdir(os.path.join(edge_path, d))]
  35.     if versions:
  36.         return versions[0]
  37.     else:
  38.         return None
  39.  
  40. # Function to delete Edge
  41. def uninstall_edge(version):
  42.     """
  43.    Uninstall Microsoft Edge Spyware using Command Prompt.
  44.    
  45.    Args:
  46.    - version (str): The version number of Microsoft Edge Spyware to uninstall.
  47.    """
  48.     if version is None:
  49.         print("Microsoft Edge Spyware is not installed.")
  50.         return
  51.    
  52.     # Navigate to Edge's Installer folder
  53.     installer_path = os.path.join(os.getenv("ProgramFiles(x86)"), "Microsoft", "Edge", "Application", version, "Installer")
  54.     os.chdir(installer_path)
  55.    
  56.     # Uninstall Edge using Command Prompt
  57.     subprocess.run(["setup.exe", "--uninstall", "--system-level", "--verbose-logging", "--force-uninstall"])
  58.  
  59. # Function to prevent Edge automatic reinstall
  60. def prevent_edge_reinstall():
  61.     """
  62.    Prevent Microsoft Edge Spyware from being automatically reinstalled by modifying the registry.
  63.    """
  64.     # Open Registry Editor
  65.     key_path = r"SOFTWARE\Microsoft"
  66.     key_name = "EdgeUpdate"
  67.     value_name = "DoNotUpdateToEdgeWithChromium"
  68.  
  69.     with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path, 0, winreg.KEY_ALL_ACCESS) as key:
  70.         # Create EdgeUpdate key
  71.         try:
  72.             winreg.CreateKeyEx(key, key_name)
  73.         except:
  74.             pass
  75.  
  76.         # Create DWORD Value
  77.         try:
  78.             value = winreg.SetValueEx(key, value_name, 0, winreg.REG_DWORD, 1)
  79.         except:
  80.             pass
  81.  
  82. if __name__ == "__main__":
  83.     edge_version = get_edge_version()
  84.     uninstall_edge(edge_version)
  85.     prevent_edge_reinstall()
  86.     print("Microsoft Edge Spyware has been uninstalled and prevented from being automatically reinstalled because it sucks!")
  87.  
  88.  
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement