I am trying to deploy a script via our Group Policy that will run in the background and watch for a process called "3dsmax.exe". Each time this process is started, I want to make sure it's priority level is set to "low".
My Powershell understanding is extremely limited. I tried combining the following using different forums but that does not seem to work and I beleive this will terminate after first occurrence which is not preferable. I use "calc.exe" as a testing process.
#requires -version 2.0
Register-WmiEvent -Class win32_ProcessStartTrace -SourceIdentifier processStarted
$prog = 'calc.exe'
$newEvent = Wait-Event -SourceIdentifier processStarted
If ($progs -match $newEvent.SourceEventArgs.NewEvent.ProcessName)
{
$prog = Get-Process -Name calc
$prog.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::Low
}
Any help would be super:)
Here is an alternative method. The "::Low", was not recognized when I tested, had to use ::Idle. EDIT: added foreach ? | loop to suppress error in case of multiple instances. Added Idle loop to begin of script to catch any pre-existing processes upon open.
And here is a little .vbs snip to open the app invisibly, so your users don't get a powershell window.