Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: disable_copilot.py
- # Version: 1.00
- # Author: Jeoi Reqi
- """
- This script disables the Windows CoPilot AI feature in Windows by creating registry keys and DWORD values.
- Requirements:
- - Python 3
- - Elevated Administrator Permissions
- Usage:
- 1. Ensure the script is run with Python 3.
- 2. Make sure to execute the script with elevated administrator permissions.
- 3. Run the script to disable the CoPilot AI feature.
- Registry Modification Notes:
- - This script creates the necessary registry keys and DWORD values to disable Windows CoPilot AI by editing the Windows registry.
- - It is recommended to create a backup of the registry before making any changes.
- """
- import winreg
- # Function to create the registry keys
- def create_registry_key(root_key, key_path):
- """
- Create a registry key.
- Args:
- root_key (HKEY): The root key of the registry.
- key_path (str): The path to the registry key.
- Raises:
- Exception: If an error occurs while creating the registry key.
- """
- try:
- with winreg.CreateKey(root_key, key_path) as key:
- print(f"Created registry key: {key_path}")
- except Exception as e:
- print(f"Error creating registry key: {e}")
- # Function to create the dword values
- def create_registry_value(root_key, key_path, value_name, value_data):
- """
- Create a DWORD registry value.
- Args:
- root_key (HKEY): The root key of the registry.
- key_path (str): The path to the registry key.
- value_name (str): The name of the registry value.
- value_data (int): The data of the DWORD registry value.
- Raises:
- Exception: If an error occurs while creating the registry value.
- """
- try:
- with winreg.OpenKey(root_key, key_path, 0, winreg.KEY_WRITE) as key:
- winreg.SetValueEx(key, value_name, 0, winreg.REG_DWORD, value_data)
- print(f"Created registry value: {value_name} = {value_data}")
- except Exception as e:
- print(f"Error creating registry value: {e}")
- # Function to disable the CoPilot AI
- def disable_copilot():
- """
- Disable the Windows CoPilot AI feature by creating registry keys and DWORD values.
- The function iterates through specified registry key paths and creates the necessary keys and DWORD values
- to disable the Windows CoPilot AI feature. It prints messages indicating the success or failure of each operation.
- Note:
- - Elevated administrator permissions are required to edit the registry.
- """
- key_paths = [
- (winreg.HKEY_CURRENT_USER, r"Software\Policies\Microsoft\Windows\WindowsCopilot"),
- (winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Policies\Microsoft\Windows\WindowsCopilot")
- ]
- value_data = 1
- for root_key, key_path in key_paths:
- create_registry_key(root_key, key_path)
- create_registry_value(root_key, key_path, "TurnOffWindowsCopilot", value_data)
- if __name__ == "__main__":
- disable_copilot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement