Same thing.  Code runs and I get nothing.  That's really weird. 

On Friday, February 17, 2017 at 3:06:47 PM UTC-5, akc...@gmail.com wrote:
>
> I copied your code from playground.  I will make that change and let you 
> know.
>
>
> On Friday, February 17, 2017 at 2:07:38 PM UTC-5, Egon wrote:
>>
>> Is your code up to date?
>> What happens, if you do:
>> fmt.Println(service, err)
>> fmt.Println(service.Config())
>>
>> On Friday, 17 February 2017 20:42:00 UTC+2, akc...@gmail.com wrote:
>>>
>>> What's driving me crazy is that if I change the name of the service 
>>> being passed to something like "thisdoesnotexist" I don't get an error.   I 
>>> would expect to see a error when it reaches this line in the function:
>>>
>>> service, err := manager.OpenService(name)
>>> if err != nil {
>>>        return fmt.Errorf("service %s does not exist: %v", name, err)
>>> }
>>>
>>>
>>>
>>>
>>> On Friday, February 17, 2017 at 11:42:24 AM UTC-5, Egon wrote:
>>>>
>>>> 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.

Reply via email to