Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: advanced_mega_registry_toggle.py
- # Version: 1.00
- # Author: Jeoi Reqi
- """
- This script manages Windows registry settings related to system configurations.
- It provides functions to retrieve the current value of specific registry entries and set them to a new value.
- If the registry does not exist, it will be created and set to 'Disabled'.
- Functions:
- 1. get_registry_value(value_name):
- - Retrieves the current value of a specified registry entry.
- 2. set_registry_value(value_name, value_data):
- - Sets a registry entry to a specified value.
- 3. main():
- - Orchestrates the execution flow, displaying current registry values, accepting user input to toggle them, and updating the registry accordingly.
- Requirements:
- - Python3.x
- - Windows 10+
- Usage:
- 1. Ensure Python3 is installed on your Windows system.
- 2. Run the script from the command line or terminal.
- 3. Follow the on-screen instructions to view and toggle registry values.
- Additional Notes:
- - Exercise caution when modifying registry values to avoid system instability or data loss.
- - Always back up important data and registry settings before making any modifications.
- - Use this script responsibly and at your own risk.
- - The author and contributors are not liable for any damage caused by its usage.
- """
- import subprocess
- def get_registry_value(value_name):
- """
- Get the current value of a registry value.
- Args:
- value_name (str): Name of the registry value.
- Returns:
- int: Current data value of the registry value.
- """
- result = subprocess.run(
- [
- "reg",
- "query",
- "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
- "/v",
- value_name,
- ],
- capture_output=True,
- text=True,
- )
- if "REG_DWORD" in result.stdout:
- lines = result.stdout.strip().split("\n")
- for line in lines:
- if "REG_DWORD" in line:
- parts = line.split()
- return int(parts[-1], 16) # Convert hexadecimal to decimal
- return None
- def create_registry_entry(value_name, value_data):
- """
- Create a new registry entry with the specified value.
- Args:
- value_name (str): Name of the registry value.
- value_data (int): Data for the new registry value.
- Returns:
- None
- """
- subprocess.run(
- [
- "reg",
- "add",
- "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
- "/v",
- value_name,
- "/t",
- "REG_DWORD",
- "/d",
- str(value_data),
- "/f",
- ],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- )
- # Dictionary mapping registry value names to their default data values
- DEFAULT_VALUES = {
- "AutoCheckSelect": get_registry_value("AutoCheckSelect"),
- "DisablePreviewDesktop": get_registry_value("DisablePreviewDesktop"),
- "DontPrettyPath": get_registry_value("DontPrettyPath"),
- "EnableSnapAssistFlyout": get_registry_value("EnableSnapAssistFlyout"),
- "Filter": get_registry_value("Filter"),
- "HideFileExt": get_registry_value("HideFileExt"),
- "HideIcons": get_registry_value("HideIcons"),
- "Hidden": get_registry_value("Hidden"),
- "IconsOnly": get_registry_value("IconsOnly"),
- "ListviewAlphaSelect": get_registry_value("ListviewAlphaSelect"),
- "ListviewShadow": get_registry_value("ListviewShadow"),
- "MapNetDrvBtn": get_registry_value("MapNetDrvBtn"),
- "MMTaskbarGlomLevel": get_registry_value("MMTaskbarGlomLevel"),
- "NavPaneShowAllFolders": get_registry_value("NavPaneShowAllFolders"),
- "PerformedOneTimeHideOfShowDesktopButtonForCopilot": get_registry_value(
- "PerformedOneTimeHideOfShowDesktopButtonForCopilot"
- ),
- "ReindexedProfile": get_registry_value("ReindexedProfile"),
- "SeparateProcess": get_registry_value("SeparateProcess"),
- "ServerAdminUI": get_registry_value("ServerAdminUI"),
- "ShowCortanaButton": get_registry_value("ShowCortanaButton"),
- "ShowCompColor": get_registry_value("ShowCompColor"),
- "ShowCopilotButton": get_registry_value("ShowCopilotButton"),
- "ShowInfoTip": get_registry_value("ShowInfoTip"),
- "ShowSecondsInSystemClock": get_registry_value("ShowSecondsInSystemClock"),
- "ShowStatusBar": get_registry_value("ShowStatusBar"),
- "ShowSuperHidden": get_registry_value("ShowSuperHidden"),
- "ShowTypeOverlay": get_registry_value("ShowTypeOverlay"),
- "StartMenuInit": get_registry_value("StartMenuInit"),
- "StartMigratedBrowserPin": get_registry_value("StartMigratedBrowserPin"),
- "StartShownOnUpgrade": get_registry_value("StartShownOnUpgrade"),
- "Start_TrackProgs": get_registry_value("Start_TrackProgs"),
- "TaskbarAl": get_registry_value("TaskbarAl"),
- "TaskbarAnimations": get_registry_value("TaskbarAnimations"),
- "TaskbarBadges": get_registry_value("TaskbarBadges"),
- "TaskbarDa": get_registry_value("TaskbarDa"),
- "TaskbarFlashing": get_registry_value("TaskbarFlashing"),
- "TaskbarGlomLevel": get_registry_value("TaskbarGlomLevel"),
- "TaskbarMigratedBrowserPin": get_registry_value("TaskbarMigratedBrowserPin"),
- "TaskbarMn": get_registry_value("TaskbarMn"),
- "TaskbarSd": get_registry_value("TaskbarSd"),
- "TaskbarSi": get_registry_value("TaskbarSi"),
- "TaskbarSizeMove": get_registry_value("TaskbarSizeMove"),
- "TaskbarSmallIcons": get_registry_value("TaskbarSmallIcons"),
- "TaskbarAutoHideInTabletMode": get_registry_value("TaskbarAutoHideInTabletMode"),
- "WebView": get_registry_value("WebView"),
- "WinXMigrationLevel": get_registry_value("WinXMigrationLevel"),
- }
- def set_registry_value(value_name, value_data):
- """
- Set a registry value.
- Args:
- value_name (str): Name of the registry value.
- value_data (int): Data to set for the registry value.
- Returns:
- None
- """
- subprocess.run(
- [
- "reg",
- "add",
- "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
- "/v",
- value_name,
- "/t",
- "REG_DWORD",
- "/d",
- str(value_data),
- "/f",
- ],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- )
- def main():
- sorted_values = sorted(DEFAULT_VALUES.items(), key=lambda x: x[0])
- max_name_length = max(len(name) for name, _ in sorted_values)
- print("\n\n\t\t::ADVANCED MEGA REGISTRY TOGGLE::\n\n")
- for idx, (name, default_value) in enumerate(sorted_values, start=1):
- idx_str = f"{idx:02d}" # Preface single-digit option numbers with a 0
- current_value = get_registry_value(name)
- if current_value is not None:
- state = "Enabled" if current_value else "Disabled"
- print(f"{idx_str}: {name.ljust(max_name_length)}: {state}")
- else:
- print(f"{idx_str}: {name.ljust(max_name_length)}: Not found")
- print("\nEnter the number of the option to toggle (or type '0' to quit):")
- while True:
- choice = input("> ")
- if choice == "0":
- print("\n\tExiting Program...\tGoodBye!")
- break
- try:
- choice = int(choice)
- if choice < 1 or choice > len(DEFAULT_VALUES):
- print(
- "\nInvalid option. Please enter a number between 1 and",
- len(DEFAULT_VALUES),
- )
- continue
- except ValueError:
- print("\nInvalid input. Please enter a number or '0' to quit.\n")
- continue
- # Toggle the selected option
- value_name = sorted_values[choice - 1][0]
- current_value = get_registry_value(value_name)
- if current_value is not None:
- new_value = 1 if current_value == 0 else 0
- set_registry_value(value_name, new_value)
- print(f"{value_name}: {'Enabled' if new_value else 'Disabled'}\n")
- else:
- # If registry entry doesn't exist, create it with default value 0
- create_registry_entry(value_name, 0)
- print(f"{value_name}: Created and set to 'Disabled'\n")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement