How can I get the list of currently installed services in golang under Windows?
I need something like:
List of currently running process in golang
but for services and not process.
How can I get the list of currently installed services in golang under Windows?
I need something like:
List of currently running process in golang
but for services and not process.
There is no such function in the standard library and there will likely never be.
Consider using one of the functions in os/exec
to launch a Windows program that will list the available services and parse its output (e.g. "sc query state=all
").
This is an old post, but figured I would share this link anyways. https://godoc.org/golang.org/x/sys/windows/svc/mgr
This package provides an API for creating, controlling and listing windows services on both the local and remote systems.
I copied the following text from the above link:
func (m *Mgr) ListServices() ([]string, error)
ListServices enumerates services in the specified service control manager database m. If the caller does not have the SERVICE_QUERY_STATUS
access right to a service, the service is silently omitted from the list of services returned.