Try this: https://play.golang.org/p/b5EPbHD6Bm
I'm guessing you are getting "Access Denied" and not seeing the error. + Egon On Friday, 17 February 2017 18:07:34 UTC+2, akc...@gmail.com wrote: > > I've just started learning the language and went through some of the > packages that deal with file operations and that went well. Has anyone had > experience with starting and stopping windows services? I went and ran a go > get on package: "golang.org/x/sys/windows/svc/mgr". Looking around and > that seems like the correct package to be using? I wanted to do a simple > program to start the Printer Spooler service a windows 7 machine as a test > but I seem to be striking out. > > package main > > import ( > "golang.org/x/sys/windows/svc/mgr" > "fmt" > ) > > > func startService(name string) error { > m, err := mgr.Connect() > if err != nil { > return fmt.Errorf("Cannot connect to manager %v", err) > } > defer m.Disconnect() > s, err := m.OpenService(name) > if err != nil { > return fmt.Errorf("service %s does not exist", name) > } > defer s.Close() > s.Start() > if err != nil { > return fmt.Errorf("could not start the service: %v", err) > } > return nil > } > > > func main() { > startService("Spooler") > } > > > > If anyone has any examples or point out what I'm doing wrong I'd > appreciate it. Thanks in advance! > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.