From 380dcf887eeb2694bdc25540951e7b7259a2f145 Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Mon, 10 Oct 2022 23:59:33 +0200 Subject: [PATCH] Replace deprecated IsAnInteractiveSession() call (#344) Using the service manager from an remote ssh command promt fails with `The service process could not connect to the service controller` Thanks to the detailed analysis from @kelseyma the fix was very straight forward. Using IsWindowsService() solved this problem for me. The mentioned issue at https://github.com/golang/go/issues/44921 has also been fixed in the meantime, so there is no reason not to use IsWindowsService() instead. Fixes #300 --- service_windows.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service_windows.go b/service_windows.go index 6b0333f3..2b854d77 100644 --- a/service_windows.go +++ b/service_windows.go @@ -149,11 +149,11 @@ func (l WindowsLogger) NInfof(eventID uint32, format string, a ...interface{}) e var interactive = false func init() { - var err error - interactive, err = svc.IsAnInteractiveSession() + isService, err := svc.IsWindowsService() if err != nil { panic(err) } + interactive = !isService } func (ws *windowsService) String() string {