Advertisement
Python253

file_visibility_options

Apr 23rd, 2024
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.40 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Filename: file_visibility_options.py
  4. # Version: 1.00
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. This script allows users to toggle visibility settings related to files and file extensions in Windows by modifying registry values. It provides options to enable or disable hidden files, file extensions, and super hidden files. The script verifies the registry path before presenting the options menu.
  9.  
  10. Requirements:
  11. - Python 3.x
  12. - Windows operating system
  13.  
  14. Functions:
  15. - set_registry_value(key, value_name, value_data): Sets a registry value.
  16. - main(): Main function to display the options menu and handle user input.
  17.  
  18. Usage:
  19. 1. Run the script in a Python environment.
  20. 2. Follow the on-screen instructions to enable or disable file visibility settings.
  21. 3. Type '0' to exit the script.
  22.  
  23. Additional Notes:
  24. - This script modifies the Windows registry. Exercise caution when using it.
  25. - Always verify the changes made by the script in the registry editor.
  26. """
  27.  
  28. import subprocess
  29.  
  30.  
  31. def set_registry_value(key, value_name, value_data):
  32.     """
  33.    Set a registry value.
  34.  
  35.    Args:
  36.        key (str): Registry key path.
  37.        value_name (str): Name of the registry value.
  38.        value_data (int): Data to set for the registry value.
  39.  
  40.    Returns:
  41.        None
  42.    """
  43.     subprocess.run(
  44.         [
  45.             "reg",
  46.             "add",
  47.             key,
  48.             "/t",
  49.             "REG_DWORD",
  50.             "/v",
  51.             value_name,
  52.             "/d",
  53.             str(value_data),
  54.             "/f",
  55.         ],
  56.         stdout=subprocess.DEVNULL,
  57.         stderr=subprocess.DEVNULL,
  58.     )
  59.  
  60.  
  61. def main():
  62.     """
  63.    Display the options menu and handle user input.
  64.  
  65.    Returns:
  66.        None
  67.    """
  68.     while True:
  69.         print(
  70.             "-------------------------------------------------------------------------------\n"
  71.             "::VERIFY PATH::\n"
  72.             "[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced]\n"
  73.             "-------------------------------------------------------------------------------\n"
  74.         )
  75.         print("\tChoose an option:\n")
  76.         print("\t1. Enable Hidden Files")
  77.         print("\t2. Disable Hidden Files")
  78.         print("\t3. Enable File Extensions")
  79.         print("\t4. Disable File Extensions")
  80.         print("\t5. Enable Super Hidden Files")
  81.         print("\t6. Disable Super Hidden Files\n")
  82.         choice = input("\tEnter your choice (Or type '0' to exit): ")
  83.  
  84.         if choice == "0":
  85.             print("\n\tExiting...\tGoodBye!\n")
  86.             break
  87.         elif choice == "1":
  88.             set_registry_value(
  89.                 "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
  90.                 "Hidden",
  91.                 1,
  92.             )
  93.             print("\n\n\t- Hidden Files Enabled!\n")
  94.         elif choice == "2":
  95.             set_registry_value(
  96.                 "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
  97.                 "Hidden",
  98.                 0,
  99.             )
  100.             print("\n\n\t- Hidden Files Disabled!\n")
  101.         elif choice == "3":
  102.             set_registry_value(
  103.                 "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
  104.                 "HideFileExt",
  105.                 0,
  106.             )
  107.             print("\n\n\t- File Extensions Enabled!\n")
  108.         elif choice == "4":
  109.             set_registry_value(
  110.                 "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
  111.                 "HideFileExt",
  112.                 1,
  113.             )
  114.             print("\n\n\t- File Extensions Disabled!\n")
  115.         elif choice == "5":
  116.             set_registry_value(
  117.                 "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
  118.                 "ShowSuperHidden",
  119.                 1,
  120.             )
  121.             print("\n\n\t- Super Hidden Files Enabled!\n")
  122.         elif choice == "6":
  123.             set_registry_value(
  124.                 "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
  125.                 "ShowSuperHidden",
  126.                 0,
  127.             )
  128.             print("\n\n\t- Super Hidden Files Disabled!\n")
  129.         else:
  130.             print("\n\n\t! Invalid choice !\n")
  131.  
  132.  
  133. if __name__ == "__main__":
  134.     main()
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement