我正在尝试通过我们的组策略部署一个脚本,该脚本将在后台运行并监视一个名为“3dsmax.exe”的进程。每次启动此过程时,我都想确保它的优先级设置为“低”。
我对 Powershell 的理解非常有限。我尝试使用不同的论坛组合以下内容,但这似乎不起作用,我相信这将在第一次出现后终止,这是不可取的。我使用“calc.exe”作为测试过程。
#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
}
任何帮助都会很棒:)