Created
August 4, 2022 21:31
-
-
Save Katzenwerfer/ef725aa5aaed126615766d3ce0770ed6 to your computer and use it in GitHub Desktop.
Script to persistently set the priority of an application that matches the specified name
This file contains 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
Set-PSDebug -Trace 0 | |
$process = Get-Process -Id $pid | |
$process.PriorityClass = 'Idle' | |
$Application = "" # Name of the application (Get-Process) | |
$Priority = "" # Priority (Idle|BelowNormal|Normal|AboveNormal|High|RealTime) | |
function Set-Priority { | |
$process = Get-Process -Name "$Application" | |
$process.PriorityClass = "$Priority" | |
} | |
function Find-Process { | |
try { | |
Get-Process -Name "$Application" -ErrorAction "Stop" | |
Set-Priority | |
} catch [Microsoft.PowerShell.Commands.ProcessCommandException] { | |
# | |
} catch { | |
# | |
} | |
} | |
for () { | |
Find-Process | |
Start-Sleep -Seconds 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment