以特权非管理员用户身份启动服务,给出拒绝访问错误

Start service as a privileged non-admin user giving Access Denied error

我使用

安装服务
sc.exe create MyService binPath= c:\MyService\MyService.exe DisplayName= 'My Service' obj= NAM\NAMuser password= **** start= Demand

我还在以下策略中将用户 NAM\NAMuser 添加到 Control Panel\Administrative Tools\Local Security Policy: - 作为操作系统的一部分 - 从网络访问这台计算机 - 作为服务登录

但是,当我尝试使用 sc.exe start MyServicenet.ext start MyServiceNAM\NAMuser 启动服务时,出现以下错误:

System error 5 has occurred.

Access is denied.

sc.exe 命令:

[SC] StartService: OpenService FAILED 5:

Access is denied.

我还需要为用户 NAM\NAMuser 提供哪些其他 permission/policy 信息才能正常工作?

我知道一些 SO post 建议以管理员身份开始,但在我的情况下,无法向该用户授予管理员权限。

与其尝试构建一个具有管理员相关权限的科学怪人,不如授予 NAM\NAMuser 帐户 start/stop 特定服务的权限。

SubinACL is a fine choice if you are working from the command line (see Scenario 5 in the link). Go for our free Service Security Editor GUI 实用程序,如果您更喜欢点击式体验。