From 11ca68067c03405b7e39c6c6c2b82811043ff6f7 Mon Sep 17 00:00:00 2001 From: Gemo <53191371+gemone@users.noreply.github.com> Date: Wed, 29 Mar 2023 04:46:18 +0000 Subject: [PATCH] fix: use windows.UTF16PtrFromString for serviceName syscall.StringToUTF16 is Deprecated. Use UTF16FromString instead. --- service_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/service_windows.go b/service_windows.go index 2b854d77..fd9de337 100644 --- a/service_windows.go +++ b/service_windows.go @@ -231,8 +231,13 @@ func lowPrivMgr() (*mgr.Mgr, error) { } func lowPrivSvc(m *mgr.Mgr, name string) (*mgr.Service, error) { + serviceName, err := windows.UTF16PtrFromString(name) + if err != nil { + return nil, err + } + h, err := windows.OpenService( - m.Handle, syscall.StringToUTF16Ptr(name), + m.Handle, serviceName, windows.SERVICE_QUERY_CONFIG|windows.SERVICE_QUERY_STATUS|windows.SERVICE_START|windows.SERVICE_STOP) if err != nil { return nil, err