Starting remote Windows services with ServiceController and impersonation

谁说胖子不能爱 提交于 2019-11-29 14:42:40

Maybe I've found the answer:

In the impersonation method LogonUserA

use LOGON32_LOGON_SERVICE (= 5) instead of LOGON32_LOGON_INTERACTIVE.

Make sure that the user that you're impersonating is the same user that runs the service.

In my case, the user is included in Local Policies --> Start session as service. I have not tested with an user not included in that local policy.

Hope it helps!

Well, that was correct if the user you want to impersonate is a machine administrator. If it is not, then you have to give the user the particular rights to start the service.

As I am not a network admin, I didn't know how to make it, but I have found this link that explains how to do it with the subinacl tool:

To download

And finally, the command line would be:

  • subinacl /service SERVICENAME /grant=DOMAINNAME\USERNAME Users=TO

Users=TO grants start/stop permissions to the user

In this case you have to impersonate the user with the INTERACTIVE mode and not with the SERVICE mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!