Files
AetherForge/agent/deploy/priority_windows.go

28 lines
523 B
Go

//go:build windows
package deploy
import (
"fmt"
"os"
)
func SetProcessPriority(priority string) error {
class := "BelowNormal"
switch priority {
case "idle":
class = "Idle"
case "below_normal":
class = "BelowNormal"
case "normal":
class = "Normal"
case "above_normal":
class = "AboveNormal"
case "high":
class = "High"
}
pid := os.Getpid()
return HiddenRun("powershell", "-NoProfile", "-WindowStyle", "Hidden", "-Command",
fmt.Sprintf("(Get-Process -Id %d).PriorityClass = '%s'", pid, class))
}