Complete Guide to Granting Start/Stop Permissions for Windows Services to Non-Administrator Users

Nov 22, 2025 · Programming · 10 views · 7.8

Keywords: Windows Services | Permission Management | Non-Administrator Users | Service Control | Security Descriptor

Abstract: This article provides a comprehensive guide on granting start and stop permissions for specific Windows services to non-administrator users. It covers two main approaches: direct permission configuration and access through IIS, with detailed explanations of sc sdset command usage, SID acquisition techniques, permission descriptor modification, and complete C# code examples and command-line operation guidelines. Suitable for various operating system environments from Windows Server 2003 to Windows 7.

Introduction

In enterprise environments, there is often a need to grant start and stop permissions for specific Windows services to non-administrator users without providing full system administrator privileges. This requirement is particularly common in service monitoring, automated operations, and permission separation scenarios. Based on practical technical experience, this article systematically introduces two effective implementation methods.

Service Control Fundamentals

Windows service management is primarily achieved through system-provided tools and APIs. In command-line environments, the net start and net stop commands can be used to operate services:

C:/> net start <SERVICE_NAME>
C:/> net stop <SERVICE_NAME>

In programming environments, C# provides the ServiceController class for service management. The following code demonstrates how to start and stop services:

ServiceController service = new ServiceController(SERVICE_NAME);

//Start the service
if (service.Status == ServiceControllerStatus.Stopped)
{
    service.Start();
    service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10.0));
}

//Stop the service
if (service.Status == ServiceControllerStatus.Running)
{
    service.Stop();
    service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10.0));
}

Direct Permission Configuration Method

This method grants service control permissions to non-administrator users by modifying the service's permission descriptor.

Retrieving Current Permission Configuration

First, examine the current permission settings of the service:

C:/>sc sdshow <SERVICE_NAME>

The command output resembles:

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

This security descriptor contains permission information for different users and groups. Strings like CCLCSWRPWPDTLOCRRC represent specific access rights.

Obtaining User SID

To set permissions for the target user, first obtain their Security Identifier (SID). This can be queried through the registry:

LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

C# code can automate SID retrieval:

//LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList RegistryKey
RegistryKey profileList = Registry.LocalMachine.OpenSubKey(keyName);

//Get a list of SIDs corresponding to each account on the computer
string[] sidList = profileList.GetSubKeyNames();

foreach (string sid in sidList)
{
    //Based on the above names, get Registry Keys corresponding to each SID
    RegistryKey profile = Registry.LocalMachine.OpenSubKey(Path.Combine(keyName, sid));

    //SID
    string strSID = sid;
    //UserName represented by the above SID
    string strUserName = (string)profile.GetValue("ProfileImagePath");
}

Modifying Permission Descriptor

Assuming the target user's SID is S-1-5-21-2103278432-2794320136-1883075150-1000, add the permission entry (A;;RPWPCR;;;S-1-5-21-2103278432-2794320136-1883075150-1000) to the security descriptor:

sc sdset <SERVICE_NAME> "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RPWPCR;;;S-1-5-21-2103278432-2794320136-1883075150-1000)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"

Upon successful execution, the system returns [SC] SetServiceObjectSecurity SUCCESS.

Access Through IIS Method

This method indirectly controls services through web services, suitable for scenarios requiring web interface management.

Create an ASP.NET web application and deploy service control code to IIS. When setting permissions, change the target user to "NS" (Network Service):

sc sdset <SERVICE_NAME> "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RPWPCR;;;NS)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"

Service control functionality can be accessed via URL http://<server>/<webservice>.

Alternative Tool Method

In addition to direct system commands, Microsoft's subinacl.exe tool can simplify permission management:

subinacl.exe /service w3svc /grant=VMX001\job=PTO

Permission code meanings: P(Pause/Continue), T(Start), O(Stop). Complete permission codes include: F(Full Control), R(Generic Read), W(Generic Write), X(Generic Execute), L(Read Control), Q(Query Service Configuration), S(Query Service Status), E(Enumerate Dependent Services), C(Service Change Configuration), T(Start Service), O(Stop Service), P(Pause/Continue Service), I(Interrogate Service), U(Service User-Defined Control Commands).

Security Considerations and Best Practices

When granting permissions for specific services in enterprise environments, the principle of least privilege should be followed. Service management in non-domain environments requires special attention to permission isolation to avoid security risks from excessive permission allocation. Regular audits of service permission configurations are recommended to ensure compliance with enterprise security policies.

Conclusion

Through appropriate permission configuration, non-administrator users can be safely granted control permissions for specific Windows services. The direct permission configuration method provides the finest control granularity, while the IIS access method is suitable for scenarios requiring web interfaces. In practical applications, suitable methods should be selected based on specific requirements, always following security best practices.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.