Documentation
¶
Overview ¶
Package winsvc provides utilities for creating and managing Windows services.
Index ¶
- func GetAppPath() (string, error)
- func InServiceMode() bool
- func InstallService(appPath, name, displayName, desc string, params ...string) error
- func InstallServiceWithOption(appPath, name string, serviceArgs []string, options ...ServiceOption) error
- func IsAnInteractiveSession() bool
- func QueryService(name string) (string, error)
- func RemoveService(name string) error
- func RunAsService(name string, start, stop func(), isDebug bool) error
- func StartService(name string) error
- func StopService(name string) error
- type ServiceOption
- func AutoDelayStart() ServiceOption
- func AutoStart() ServiceOption
- func Dependencies(serviceName ...string) ServiceOption
- func Description(description string) ServiceOption
- func DisabledStart() ServiceOption
- func DisplayName(displayName string) ServiceOption
- func OnBootStart() ServiceOption
- func OnDemandStart() ServiceOption
- func OnSystemStart() ServiceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAppPath ¶
GetAppPath returns the absolute path of the current executable.
func InServiceMode ¶
func InServiceMode() bool
InServiceMode returns true if the current process is running as a Windows service.
func InstallService ¶
InstallService installs a Windows service with the given parameters. It takes the application path, service name, display name, description, and optional parameters.
func InstallServiceWithOption ¶
func InstallServiceWithOption(appPath, name string, serviceArgs []string, options ...ServiceOption) error
InstallServiceWithOption installs a Windows service with custom options. It takes the application path, service name, a ServiceArgsOption function, and variadic ServiceOption functions.
func IsAnInteractiveSession ¶
func IsAnInteractiveSession() bool
IsAnInteractiveSession returns true if the current process is running in an interactive session.
func QueryService ¶
QueryService returns the current status of a Windows service.
func RemoveService ¶
RemoveService removes a Windows service with the given name.
func RunAsService ¶
RunAsService runs the provided start and stop functions as a Windows service. It takes the service name, start function, stop function, and a debug flag.
func StartService ¶
StartService starts a Windows service with the given name.
func StopService ¶
StopService stops a Windows service with the given name.
Types ¶
type ServiceOption ¶
func AutoDelayStart ¶
func AutoDelayStart() ServiceOption
func AutoStart ¶
func AutoStart() ServiceOption
func Dependencies ¶
func Dependencies(serviceName ...string) ServiceOption
func Description ¶
func Description(description string) ServiceOption
func DisabledStart ¶
func DisabledStart() ServiceOption
func DisplayName ¶
func DisplayName(displayName string) ServiceOption
func OnBootStart ¶
func OnBootStart() ServiceOption
func OnDemandStart ¶
func OnDemandStart() ServiceOption
func OnSystemStart ¶
func OnSystemStart() ServiceOption