Advertisement
Python253

clipboard_fix_csv_reset

Apr 19th, 2024
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.22 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Filename: clipboard_fix_csv_reset.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. This script is designed to fix issues related to clipboard functionality on Windows systems by resetting and restarting essential services.
  9. Specifically, it targets the "Remote Desktop Services UserMode Port Redirector" and "ClipSVC" services, which are critical for clipboard operations.
  10.  
  11. The script first stops these services using the 'net stop' command, ensuring that any existing processes associated with them are terminated gracefully.
  12. It then starts the services again using the 'net start' command, effectively resetting them to their default state.
  13.  
  14. By executing this script, users can resolve common clipboard problems on Windows, such as malfunctioning clipboard operations or locked memory issues.
  15. This script provides a convenient and efficient way to address these issues without the need for manual intervention or complex troubleshooting steps.
  16.  
  17. Requirements:
  18.    - Python 3.x
  19.    - Administrative privileges may be required for execution.
  20.    
  21. Usage:
  22.    - Run the script with Python 3.x from the command line.
  23.    - Ensure administrative privileges are granted if prompted.
  24.    
  25. Additional Notes:
  26.    - Ensure 'net stop' and 'net start' commands are available.
  27.    - Verify service status post-execution for confirmation.
  28. """
  29.  
  30. import subprocess
  31.  
  32. def stop_service(service_name):
  33.     """Stop the specified Windows service."""
  34.     subprocess.run(["net", "stop", service_name], shell=True)
  35.  
  36. def start_service(service_name):
  37.     """Start the specified Windows service."""
  38.     subprocess.run(["net", "start", service_name], shell=True)
  39.  
  40. def main():
  41.     """Main function to stop and start essential services."""
  42.     services = [
  43.         "Remote Desktop Services UserMode Port Redirector",
  44.         "ClipSVC"
  45.     ]
  46.     print("\n\t\t[CLIPBOARD FIX CSV RESET]\n\n")
  47.     for service in services:
  48.         print(f"\nStopping service:\n{service}")
  49.         stop_service(service)
  50.         print(f"\nStarting service:\n{service}")
  51.         start_service(service)
  52.     print("\n\t\tAll Processes Have Completed.\n\n\t\tEnding Program... GoodBye!\n")
  53. if __name__ == "__main__":
  54.     main()
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement