Advertisement
Python253

controlpanel_shortcut

Mar 21st, 2024
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Filename: controlpanel_shortcut.py
  3. # Version: 1.00
  4. # Author: Jeoi Reqi
  5.  
  6. """
  7. CONTROL PANEL SHORTCUT:
  8.  
  9. This script creates a shortcut on the desktop that opens the Control Panel in Windows.
  10.  
  11. Requirements:
  12. - Windows operating system
  13. - pywin32 library (install via pip install pywin32)
  14.  
  15. Usage:
  16. - Run the script to create a shortcut on the desktop.
  17.  
  18. Notes:
  19. - The shortcut will be named "Control Panel.lnk".
  20. - The Control Panel will open when the shortcut is double-clicked.
  21. """
  22.  
  23. import os
  24. import win32com.client
  25.  
  26. # Define the CLSID for the Control Panel
  27. CLSID_ControlPanel = '{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}'
  28.  
  29. # Path to the desktop
  30. desktop_path = os.path.join(os.environ['USERPROFILE'], 'OneDrive', 'Desktop')
  31.  
  32. def create_control_panel_shortcut():
  33.     """
  34.    Create a shortcut to the Control Panel on the desktop.
  35.    """
  36.     # Create a shortcut object
  37.     shell = win32com.client.Dispatch('WScript.Shell')
  38.     shortcut = shell.CreateShortcut(os.path.join(desktop_path, 'Control Panel.lnk'))
  39.  
  40.     # Set the target path using the CLSID
  41.     shortcut.TargetPath = f'::{CLSID_ControlPanel}'
  42.  
  43.     # Optionally set the icon location to the Control Panel's icon
  44.     shortcut.IconLocation = '%SystemRoot%\\system32\\shell32.dll,-137'
  45.  
  46.     # Save the shortcut
  47.     shortcut.Save()
  48.  
  49. if __name__ == "__main__":
  50.     create_control_panel_shortcut()
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement