Skip to content

Instantly share code, notes, and snippets.

@jbenner-radham
Created November 26, 2013 20:02
Show Gist options
  • Save jbenner-radham/7665170 to your computer and use it in GitHub Desktop.
Save jbenner-radham/7665170 to your computer and use it in GitHub Desktop.
A terrible WDSUtil script I made up real quick in Go (FYI, I don't know how to use Go at the moment... so this is mostly a learning experiment.) to set the boot program.
package main
import (
"os"
"os/exec"
"log"
"fmt"
)
func main() {
if len(os.Args) < 4 {
println("Invalid number of arguments, we need the Device, ID and BootProgram.")
return
}
// Looks for an exe (by string name) in your system's path.
path, err := exec.LookPath("wdsutil")
if err != nil {
log.Fatal("WDSUtil is not found dawg!")
}
if len(path) > 0 {
// This is because the compile is pedantic... blarg!
}
cmd_device := fmt.Sprintf("/Device:%s", os.Args[1])
cmd_id := fmt.Sprintf("/ID:%s", os.Args[2])
cmd_boot_prog := fmt.Sprintf("/BootProgram:%s", os.Args[3])
cmd := exec.Command("wdsutil",
"/Set-Device",
cmd_device,
cmd_id,
cmd_boot_prog)
out, err := cmd.Output()
if err != nil {
println(err.Error())
return
}
if out != nil {
// Stuff...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment