From c7e6b82e87a1a88a644b90fb3759c7cde01c557c Mon Sep 17 00:00:00 2001 From: Aram Date: Thu, 10 Jun 2021 13:02:15 +0100 Subject: [PATCH] allow inteactive setting mode for windows (#253) Co-authored-by: Aram Co-authored-by: Daniel Theophanes --- service.go | 1 + service_windows.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/service.go b/service.go index 2907c02..6033981 100644 --- a/service.go +++ b/service.go @@ -190,6 +190,7 @@ func New(i Interface, c *Config) (Service, error) { // * Windows // - DelayedAutoStart bool (false) - After booting, start this service after some delay. // - Password string () - Password to use when interfacing with the system service manager. +// - Interactive bool (false) - The service can interact with the desktop. (more information https://docs.microsoft.com/en-us/windows/win32/services/interactive-services) type KeyValue map[string]interface{} // bool returns the value of the given name, assuming the value is a boolean. diff --git a/service_windows.go b/service_windows.go index c6ee3a6..b6d8314 100644 --- a/service_windows.go +++ b/service_windows.go @@ -220,6 +220,12 @@ func (ws *windowsService) Install() error { s.Close() return fmt.Errorf("service %s already exists", ws.Name) } + + serviceType := windows.SERVICE_WIN32_OWN_PROCESS + if ws.Option.bool("Interactive") { + serviceType = serviceType | windows.SERVICE_INTERACTIVE_PROCESS + } + s, err = m.CreateService(ws.Name, exepath, mgr.Config{ DisplayName: ws.DisplayName, Description: ws.Description, @@ -228,6 +234,7 @@ func (ws *windowsService) Install() error { Password: ws.Option.string("Password", ""), Dependencies: ws.Dependencies, DelayedAutoStart: ws.Option.bool("DelayedAutoStart", false), + ServiceType: serviceType, }, ws.Arguments...) if err != nil { return err