Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Created January 21, 2026 09:57
Show Gist options
  • Select an option

  • Save mschmitt/210be09fa1795dc0a7cf220dab5ca505 to your computer and use it in GitHub Desktop.

Select an option

Save mschmitt/210be09fa1795dc0a7cf220dab5ca505 to your computer and use it in GitHub Desktop.
Automatic Windows process priority script
# 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