Skip to content

Instantly share code, notes, and snippets.

@jpramirez
Last active February 16, 2019 00:58
Show Gist options
  • Save jpramirez/b68f9b5ed74b9697a29128e441decf79 to your computer and use it in GitHub Desktop.
Save jpramirez/b68f9b5ed74b9697a29128e441decf79 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