Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: clipboard_fix_csv_reset.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- - This script is designed to fix issues related to clipboard functionality on Windows systems by resetting and restarting essential services.
- - Specifically, it targets the "Remote Desktop Services UserMode Port Redirector" and "ClipSVC" services, which are critical for clipboard operations.
- - The script first stops these services using the 'net stop' command, ensuring that any existing processes associated with them are terminated gracefully.
- - It then starts the services again using the 'net start' command, effectively resetting them to their default state.
- - By executing this script, users can resolve common clipboard problems on Windows, such as malfunctioning clipboard operations or locked memory issues.
- - This script provides a convenient and efficient way to address these issues without the need for manual intervention or complex troubleshooting steps.
- Requirements:
- - Python 3.x
- - Administrative privileges may be required for execution.
- Usage:
- - Run the script with Python 3.x from the command line.
- - Ensure administrative privileges are granted if prompted.
- Example Output:
- [CLIPBOARD FIX CSV RESET]
- Clearing clipboard...
- Stopping service:
- Remote Desktop Services UserMode Port Redirector
- The Remote Desktop Services UserMode Port Redirector service is stopping.
- The Remote Desktop Services UserMode Port Redirector service was stopped successfully.
- Starting service:
- Remote Desktop Services UserMode Port Redirector
- The Remote Desktop Services UserMode Port Redirector service is starting.
- The Remote Desktop Services UserMode Port Redirector service was started successfully.
- Stopping service:
- ClipSVC
- The Client License Service (ClipSVC) service is stopping.
- The Client License Service (ClipSVC) service was stopped successfully.
- Starting service:
- ClipSVC
- The Client License Service (ClipSVC) service is starting.
- The Client License Service (ClipSVC) service was started successfully.
- - All Processes Have Completed.
- - Clipboard Data Has Been Cleared.
- - Services Have All Been Reset.
- Ending Program... GoodBye!
- Additional Notes:
- - Ensure 'net stop' and 'net start' commands are available.
- - Verify service status post-execution for confirmation.
- """
- import subprocess
- import ctypes
- def disable_clipboard():
- """
- Clears the current content of the clipboard.
- """
- ctypes.windll.user32.OpenClipboard(0)
- ctypes.windll.user32.EmptyClipboard()
- ctypes.windll.user32.CloseClipboard()
- def stop_service(service_name):
- """Stop the specified Windows service."""
- subprocess.run(["net", "stop", service_name], shell=True)
- def start_service(service_name):
- """Start the specified Windows service."""
- subprocess.run(["net", "start", service_name], shell=True)
- def main():
- """Main function to stop and start essential services."""
- services = [
- "Remote Desktop Services UserMode Port Redirector",
- "ClipSVC"
- ]
- print("\n\t\t[CLIPBOARD FIX CSV RESET]\n\n")
- # Clear clipboard before stopping services
- print("Clearing clipboard...")
- disable_clipboard()
- for service in services:
- print(f"\nStopping service:\n{service}")
- stop_service(service)
- print(f"\nStarting service:\n{service}")
- start_service(service)
- print("\n\t\t- All Processes Have Completed.\n\t\t- Clipboard Data Has Been Cleared.\n\t\t- Services Have All Been Reset.\n\n\t\t Ending Program... GoodBye!\n")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement