66

We have a suite of Windows Services running on our servers which perform a bunch of automated tasks independently of one another, with the exception of one service which looks after the other services.

In the event that one of the services should fail to respond or hang, this service attempts to restart the service and, if an exception is thrown during the attempt, emails the support team instead, so that they can restart the service themselves.

Having done a little research, I've come across a few 'solutions' which range from the workaround mentioned in KB907460 to giving the account under which the service is running administrator rights.

I'm not comfortable with either of these methods - I don't understand the consequences of the first method as outlined in Microsoft's knowledge base article, but I definitely don't want to give administrator access to the account under which the service is running.

I've taken a quick look through the Local Security Policy and other than the policy which defines whether or not an account can log on as a service, I can't see anything else which looks like it refers to services.

We're running this on Server 2003 and Server 2008, so any ideas or pointers would be graciously received!


Clarification: I don't want to grant the ability to start/stop/restart ALL services to a given user or group - I want to be able to grant the permission to do so on specific services only, to a given user or group.


Further Clarification: The servers I need to grant these permissions on do not belong to a domain - they are two internet-facing servers which receive files, process them and send them on to third parties, as well as serving a couple of websites, so Active Directory Group Policy isn't possible. Sorry that I didn't make this clearer.

3
  • you might also take a look at this article from ms, which also points to GP modifications: support.microsoft.com/kb/256345
    – user56090
    Oct 4, 2010 at 16:08
  • 3
    Sorry I missed you... I was busy. You were looking for something like this: serverfault.com/questions/15147/… Oct 7, 2010 at 1:54
  • I know this is a very old question, but did you consider using the 'recovery' options in the Windows service manager?
    – Tim Long
    Apr 29, 2013 at 9:08

5 Answers 5

54

There doesn't appear to be a GUI-based way of doing this unless you're joined to a domain - at least not one I could find anywhere - so I did a bit more digging and I've found an answer that works for our situation.

I didn't understand what the string representation meant in the knowledge base article, but doing a bit of digging led me to discover that it's SDDL syntax. Further digging led me to this article by Alun Jones which explains how to get the security descriptor for a service and what each bit means. MS KB914392 has more details.

To append to the service's existing security descriptor, use sc sdshow "Service Name" to get the existing descriptor. If this is a plain old .NET Windows Service - as is the case with ours - the security descriptor should look something like this:

D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOC
RRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CR;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)S:(AU;FA
;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)

We needed to grant permissions RP (to start the service), WP (to stop the service), DT (to pause/continue the service) and LO (to query the service's current status). This could be done by adding our service account to the Power Users group, but I only want to grant individual access to the account under which the maintenance service runs.

Using runas to open a command prompt under the service account, I ran whoami /all which gave me the SID of the service account, and then constructed the additional SDDL below:

(A;;RPWPDTLO;;;S-x-x-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx)

This then gets added to the D: section of the SDDL string above:

D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOC
RRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CR;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)(A;;RPWP
DTLO;;;S-x-x-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx)S:(AU;FA;CCDCLCSWRPWPDTLOC
RSDRCWDWO;;;WD)

This is then applied to the service using the sc sdset command (before the S: text):

sc sdset "Service Name" D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;
CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CR;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU
)(A;;RPWPDTLO;;;S-x-x-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx)S:(AU;FA;CCDCLCSW
RPWPDTLOCRSDRCWDWO;;;WD)

If all goes according to plan, the service can then be started, stopped, paused and have it's status queried by the user defined by the SID above.

4
  • 10
    For an easier way of doing the same thing, you should look at using SetACL.exe. Here is an example of how to use it to set permissions on a service: SetACL.exe -on "\\server1\W32Time" -ot srv -actn ace -ace "n:domain1\group1;p:start_stop" Aug 15, 2011 at 23:39
  • 2
    You could use Process Hacker (processhacker.sourceforge.net) for a GUI to configure all services. It includes hidden services and allows you to configure more settings of a service like the binary path - and the permissions.
    – ygoe
    May 4, 2013 at 12:44
  • 1
    The CoreTech gui worked for me. Hard to believe that GUI doesn't exist in windows already. Reading the answers here how can it possibly be this hard? Big failing on Microsoft's behalf.
    – MikeKulls
    Jan 11, 2016 at 2:28
  • 1
    I like to add CCLCSW to the SDDL permissions (in addition to RPWPDTLO) so I can also see the service listed when I run Get-Service (which first requires modifying the SDDL for the scmanager service control manager service to be able to list accessible services). I also needed SW to be able to restart certain services.
    – Baodad
    Sep 25, 2018 at 23:01
35

I just had the same problem.
You could use SubInACL.exe from the Resource Kit. Download the standalone utility here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23510

Use msiexec /a PathToMSIFile /qb TARGETDIR=DirectoryToExtractTo to extract the files if you don't want to install the .msi

  1. Open a command prompt as Administrator
  2. Go to the directory where you placed the .exe
  3. Run subinacl /service SERVICE_NAME /grant=COMPUTER_NAME\USERNAME=TOP

T = Start service
O = Stop service
P = Pause/continue service

Full reference: How to grant users rights to manage services in Windows 2000
or type subinacl /help

Note: don't try subinacl /service SERVICE_NAME /perm as it could get you into trouble (lesson learned :P). The name could be misleading (perm != permission), as it deletes all permissions to all users (even Admin!).

3
  • Can't merge SO and SF accounts sorry Pat.
    – Chopper3
    Sep 21, 2011 at 8:10
  • @Chopper3 Thanks for your response. In fact I have 2 SO accounts: one is registered and associated with this SF account; the other one is an unregistered SO account I had before registering (used the same email address). I was hoping the two could be merged so I can track the post I've done before. As mentioned here I tried to flag a post but couldn't do it on SO (1 reputation). This is why I flagged this post. I also tried to email [email protected] more than two weeks ago but didn't get any response. Could you direct me to the right place/person please?
    – patrx
    Sep 21, 2011 at 23:12
  • 1
    Checkout the details of this procedure at MSDN: support.microsoft.com/?kbid=288129 Jun 5, 2012 at 8:08
4

You're looking for Computer Configuration - Policies - Windows Settings - Security Settings - System Services

There you can not only define the service start type, but you can configure the security ACLs for each service as well. By default, the interface will only list the services that are installed on the machine you're running the GP Editor on.

To add services that only exist on another machine:

  • export the service's reg key from the other machine
  • import on the gpedit machine
  • apply the policy
  • delete the imported key
3
  • I trust you mean to do this through gpedit.msc, as the "Manage Server" window doesn't list a policies node. If so, I can't see an item underneath the Security Settings node which references "System Services" as you suggest above, on either Server 2008 or Server 2003.
    – abitgone
    Oct 4, 2010 at 16:13
  • Ah yes. I assumed you were planning on making these changes via group policy. Oct 4, 2010 at 18:46
  • 1
    Indeed - these are not member servers. Is there a way of targeting this using local policy, or some other method?
    – abitgone
    Oct 5, 2010 at 7:45
3

I used SubinAcl (as suggested by patrx) to be able to start MySQL as a regular domain user (not admin) and it works perfectly! (the command needs however to be executed as a -local at least- Admin)

The command is:

[PATH_TO_SUBACL]\subinacl.exe /service MySQL /grant=[Domain User - Without domain]=TOP

Just note that I entered the user without prefixing it with the domain ... otherwise command fails on parsing command!

2

I'd like to recommend 3 options as solutions.

I know this is an old question, but the challenge posed in the question remains (even on later versions of Windows). And some of the answers offered are old and some no longer work (or tools offered no longer exist).

First, MikeKullis above commented above about "the CoreTech gui", but I don't see any other answer or comment that elaborates on what he meant by that. It's called Security Service Editor, and it's free. The company (CoreTech) makes several tools to help with Windows admin tasks.

I realize some folks will be leery of or balk at installing any tool, but really for the specific task of easily indicating that a given user should have permission to start/stop a specific service, it is the easiest solution. In just a couple of clicks one is presented a UI that looks like the traditional Windows file permissions editor, but it's for controlling service permissions (for a specific service, for a specific user--and offering the same UI to "add" a user, use the "find" feature to see a list of users on the machine, etc.)

Second, as for a more "built-in" solutions instead, one can add "Security Templates" to mmc, and do the same. It's a bit more fiddly, but not nearly as some other cli solutions. See a discussion of using it (and many other options, including some also mentioned on answers and comments here) in various posts such as this.

Third and finally, if someone might prefer at least to use an "MS" tool, note how that blog post (and others) discuss using the Sysinternals tool Process Explorer, which can also offer that easy permissions UI to control start/stop permissions for a given service by a given user. One modest negative is that the service has to be running (as you then use ProcExp to find the process for that service, and use a properties feature to get to a "services" tab it then offers). For some, that may beat either of the two options above.

But like Mike above, I favor the CoreTech SSE tool. It's free, simple, and has proven safe and effective in my using it on several dozen workstations and servers.

Hope the above may help others who find this question.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .