Created
January 21, 2026 09:57
-
-
Save mschmitt/210be09fa1795dc0a7cf220dab5ca505 to your computer and use it in GitHub Desktop.
Automatic Windows process priority script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # I run this from the Windows task scheduler once a minute, without elevated privileges. | |
| # Don't forget to use pythonw.exe as the interpreter. | |
| import psutil | |
| import re | |
| want_priority = { | |
| 'voicemeeter8x64.exe': psutil.HIGH_PRIORITY_CLASS, | |
| 'obs64.exe': psutil.HIGH_PRIORITY_CLASS, | |
| 'Cantabile.exe': psutil.ABOVE_NORMAL_PRIORITY_CLASS | |
| } | |
| for proc in psutil.process_iter(['pid', 'name', 'nice']): | |
| for process in want_priority: | |
| if re.search(f"^{process}$", proc.name()): | |
| if proc.nice() == want_priority[process]: | |
| print(f"{process}: nice={proc.nice()}, want={want_priority[process]}, status=no_todo") | |
| continue | |
| print(f"{process}: nice={proc.nice()}, want={want_priority[process]}, status=will_renice") | |
| try: | |
| proc.nice(want_priority[process]) | |
| except Exception as e: | |
| print(e) | |
| else: | |
| print(f"{process}: nice={proc.nice()}, want={want_priority[process]}, status=reniced") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment