Skip to content

Instantly share code, notes, and snippets.

@smallnest
Forked from jpramirez/LowPrioritySystem_linux.go
Created February 16, 2019 00:58
Show Gist options
  • Save smallnest/426e0574e118b490adeb389282d77a1a to your computer and use it in GitHub Desktop.
Save smallnest/426e0574e118b490adeb389282d77a1a to your computer and use it in GitHub Desktop.
Fast & Furious (And extremely dirty) way to low the priority value of a process for windows and linux
package components
import "syscall"
func setpriority() {
syscall.Setpriority(syscall.PRIO_PGRP, 0, 9)
}
package main
import (
"bytes"
"log"
"os/exec"
"runtime"
)
func setpriority() {
if runtime.GOOS == "windows" {
args := "process where name='setpriority' CALL setpriority 32768" //You can also use a Wildcard
command1 := "wmic"
command := exec.Command(command1, args)
// set var to get the output
var out bytes.Buffer
// set the output to our variable
command.Stdout = &out
err := command.Run()
if err != nil {
log.Println(err)
}
ret := out.String()
log.Printf("%s", ret)
}
}
package main
import (
"log"
)
func main (){
setpriority()
log.Println("Low Priority Set for Process")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment