用于检查用户是否有权启动Windows服务的命令

时间:2013-09-20 03:21:28

标签: windows service permissions command

I am creating an installer that need to stop and then start a service named "MyService".
The installer is always run as admin, But some times the user of admin group does not have a permission to start and/or stop the service.
In this case I will get access denied when I try to start the service.
I want to check prior to start/stop service that if the user have permission to do so.
Found that using 
     sc sdshow myservice
This shows the security descriptor and I can GET the SID and access level.
From this finding out access, turned out to be difficult. That it can so have that a group that this user is member of is turned to have no access to start/stop service.
Finding the list of group of a user that he belongs to, I did not get any direct method.

Is there any way to find if the user (I have user name and SID) has permission to start/stop service Myservice?
If not any direct method to get list of groups that the user is member of?

0 个答案:

没有答案