Most programs would launch with normal priories and trigger child processes with varying priority levels, depending on the programmer’s intention. Well, you haz the tool to upgrade or downgrade running processes on-the-fly as desired – or for no reason (because you can). Here goes the snippets to render such statement as ‘oh yeah,’ (aka. ‘true’).
# Change-Process-Priority.ps1
$executable="WinMergeU.exe"
$priority="RealTime";
###### Powershell 4.0 or higher ######
$processPowerShell4=get-process -name $executable;
$processPowerShell4.PriorityClass=$priority;
write-host "$executable priority has been set to $($processPowerShell4.PriorityClass)";
# Change-Process-Priority.ps1
$executable="MsMpEng.exe"
$priority="Idle";
###### PowerShell 2.0 or higher ######
$command="Get-WMIObject Win32_process -filter 'name = `"$executable`"'"
$processPowerShell2=Invoke-Expression $command;
# Convert priority to integer
$value=switch ($priority.toLower()){
"idle" {64}
"belownormal" {16384}
"normal" {32}
"abovenormal" {32768}
"high" {128}
"realtime" {256}
}
$processPowerShell2.SetPriority($value)
write-host "$executable priority has been set to a priority mapping of $($processPowerShell2.Priority)";
Categories: