You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让已登录用户安装后立即生成Per-user Windows Service实例?

每用户Windows服务实例生成问题

我正在创建一个每用户Windows服务。这类服务通过创建服务“模板”完成安装,当用户登录时,模板会转换为用户特定的服务实例,这些生成的服务会在用户登出时被自动删除。

问题出在“用户登录时”这个触发条件上:我需要服务在安装完成后立即可用,不需要提示用户重启电脑或登出。但如果在安装后直接尝试启动服务,会收到如下错误:

> sc start FooService
[SC] StartService FAILED 1058:

The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

> sc quserservice FooService
[SC] QueryLocalUserServiceName FAILED 1060:

The specified service does not exist as an installed service.

用户登出并重新登录后,用户服务实例会自动生成,此时可以通过服务控制管理器查询到实例名称并正常启动:

> sc quserservice FooService
USER SERVICE TEMPLATE FooService, LOCAL SERVICE INSTANCE FooService_6c54c18.
> sc start FooService_6c54c18
[success, status output goes here]

是否有办法让Windows为当前已登录的用户直接生成上述“本地服务实例”?


内容的提问来源于stack exchange,提问作者Artfunkel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.01 12:44:52