如何为用 Golang 编写的 windows 服务设置登录用户帐户?

How to set a login user account for a windows service written in Golang?

我将包“https://pkg.go.dev/github.com/kardianos/service”用于 运行 一个用 Go 编写的应用程序 Windows服务。

我在service.Config中设置了以下属性:

Username: "myusername"
Option: service.KeyValue{"password": "mypassword"}

当我安装程序时,出现以下错误:The account name is invalid or does not exist, or the password is invalid for the account name specified.

我应该如何设置 service.Config 的属性,以便在安装时使用指定的凭据正确地创建服务 运行?

我刚刚自己找到了解决方案。

Username:`DESKTOP-XXXXXX\myAcount`
Option: service.KeyValue{"password": "mypassword"}