allow inteactive setting mode for windows (#253)

Co-authored-by: Aram <aram.petrosyan@unity3d.com>
Co-authored-by: Daniel Theophanes <kardianos@gmail.com>
This commit is contained in:
Aram
2021-06-10 13:02:15 +01:00
committed by GitHub
parent 8eb6809ed2
commit c7e6b82e87
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -190,6 +190,7 @@ func New(i Interface, c *Config) (Service, error) {
// * Windows // * Windows
// - DelayedAutoStart bool (false) - After booting, start this service after some delay. // - DelayedAutoStart bool (false) - After booting, start this service after some delay.
// - Password string () - Password to use when interfacing with the system service manager. // - 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{} type KeyValue map[string]interface{}
// bool returns the value of the given name, assuming the value is a boolean. // bool returns the value of the given name, assuming the value is a boolean.
+7
View File
@@ -220,6 +220,12 @@ func (ws *windowsService) Install() error {
s.Close() s.Close()
return fmt.Errorf("service %s already exists", ws.Name) 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{ s, err = m.CreateService(ws.Name, exepath, mgr.Config{
DisplayName: ws.DisplayName, DisplayName: ws.DisplayName,
Description: ws.Description, Description: ws.Description,
@@ -228,6 +234,7 @@ func (ws *windowsService) Install() error {
Password: ws.Option.string("Password", ""), Password: ws.Option.string("Password", ""),
Dependencies: ws.Dependencies, Dependencies: ws.Dependencies,
DelayedAutoStart: ws.Option.bool("DelayedAutoStart", false), DelayedAutoStart: ws.Option.bool("DelayedAutoStart", false),
ServiceType: serviceType,
}, ws.Arguments...) }, ws.Arguments...)
if err != nil { if err != nil {
return err return err