Created
November 26, 2013 20:02
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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