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

huangapple go评论71阅读模式
英文:

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"}

当我安装程序时,我收到以下错误消息:"帐户名无效或不存在,或者密码对于指定的帐户名无效。"

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

英文:

I use the package "https://pkg.go.dev/github.com/kardianos/service" to run an application written in Go as a Windows service.

I set the following attributes in service.Config:

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

When I then install the program, I get the following error: The account name is invalid or does not exist, or the password is invalid for the account name specified.

How should I set attributes of service.Config to make the service run properly with specified the credentials when installed?

答案1

得分: 0

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

用户名:`DESKTOP-XXXXXX\myAcount`
选项:service.KeyValue{"password": "mypassword"}
英文:

I just found out the solution myself.

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

huangapple
  • 本文由 发表于 2021年6月3日 23:22:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/67824263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定