func newManagerConn() (mgrInterface, error) { s, err := mgr.Connect() if err != nil { return nil, err } return &manager{m: s}, nil }
// CreateService wraps Mgr.OpenService method. It returns a windowsService object. // This allows us to stub out this module for testing. func (m *manager) OpenService(name string) (windowsService, error) { s, err := mgr.Connect() if err != nil { return nil, err } defer s.Disconnect() return s.OpenService(name) }
// CreateService wraps Mgr.CreateService method. func (m *manager) CreateService(name, exepath string, c mgr.Config, args ...string) (windowsService, error) { s, err := mgr.Connect() if err != nil { return nil, err } defer s.Disconnect() return s.CreateService(name, exepath, c, args...) }
// CreateService wraps Mgr.CreateService method. func (m *manager) CreateService(name, exepath string, c mgr.Config, args ...string) (windowsService, error) { // The Create function relies on the fact that this calls Connect(which connects to localhost) and not // ConnectRemote. If we get to the point where we need to call ConnectRemote we need to stop using // series.HostSeries inside Create. s, err := mgr.Connect() if err != nil { return nil, err } defer s.Disconnect() return s.CreateService(name, exepath, c, args...) }
// CreateService wraps Mgr.OpenService method but returns a windows.Handle object. // This is used to access a lower level function not directly exposed by // the sys/windows package. func (m *manager) GetHandle(name string) (handle windows.Handle, err error) { s, err := mgr.Connect() if err != nil { return handle, err } defer s.Disconnect() service, err := s.OpenService(name) if err != nil { return handle, err } return service.Handle, nil }