如何为指定用户创建Windows服务?

发布于 2024-07-24 07:28:49 字数 137 浏览 3 评论 0原文

我构建了一个测试服务,它将消息写入本地文件。 我注意到文件的“所有者”属性始终是“管理员”,这在使用“本地系统”帐户时是相同的。 但我已将服务管理器中的“登录身份”设置更改为我的个人帐户。

我应该怎样做才能使该服务在指定帐户上运行?

I built a testing service which writes a message to a local file. I noticed the "Owner" property of the file is always "Administrator" which is same when using "Local System" account. But I have changed the "Log on as" setting to my personal account in service manager.

What should I do to make the service work on a specified account?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

深陷 2024-07-31 07:28:49

我不知道该怎么做,但您还应该将用户设置为“作为服务运行”选项。 检查 MSDN API 了解详细信息

I am not sure how to do it, but you should also set the user to "Run as a service" option. check the MSDN API for details

清晰传感 2024-07-31 07:28:49

“登录身份”设置应该可以满足您的要求。

难道是你更改登录帐户后没有创建该文件? 如果您覆盖该文件,所有者可能不会改变。

我不确定是否建议以普通用户身份登录该服务。 用户将需要“作为服务登录”权限。 如果您是管理员,则可能有此权限,但普通用户可能没有。

The "Log on as" setting should do what you want.

Could it be that you haven't created the file after you changed the logon account? If you overwrite the file, the owner will probably not change.

I'm not sure if it is advisable to log the service on as a regular user. The user will need the "log on as a service" right. You might have that if you're an administrator, but a regular user might not.

迷雾森÷林ヴ 2024-07-31 07:28:49

我应该怎么做才能提供服务
在指定帐户上工作?

您执行完全相同的操作,但在服务控制管理器中指定该特定帐户。

或者您的意思是该服务只会为特定用户运行?

What should I do to make the service
work on a specified account?

You do exactly the same, but specify that specific account in service control manager.

Or do you mean that the service will only be running for a specific user?

半边脸i 2024-07-31 07:28:49

您可以通过创建 WMI 脚本来设置服务设置来完成此操作。

据我所知,您无法对服务将自动使用的用户进行硬编码。

You could do this by creating a WMI script to set up the Service settings.

You cannot, as far as I know, hardcode the user the service will use automatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文