SoFunction
Updated on 2025-05-15

Windows SC (Service Control Service Control Tool) command detailed introduction

The Windows SC (Service Control) command is a command-line tool used to interact with Windows services. It allows users to perform various actions such as starting, stopping, pausing, continuing, and configuring services. SC commands provide a convenient way to manage services running in the operating system. These services are background programs that can be automatically started when Windows starts and run in the background as services when the system runs.

Detailed functional classification and refinement table of SC commands. SC is a service control tool in the Windows system, allowing users to interact with Windows services, including query, configuration, start, stop, delete and other operations.

Functional Category Order describe Remark
Service Query and Status sc query Query the status of the service. Displays the running status of the service, such as running, pausing, etc.
sc queryex Query the service's extended status. Returns more detailed service status information, such as service identifiers, etc.
Service Operation sc start Start the specified service. The service must have been created before starting the service.
sc stop Stop the specified service. Stop a running service.
sc pause Suspend the specified service. The service must support the pause function.
sc continue Continue suspended services. Restore a suspended service.
sc interrogate Send an inquiry request to the service and return to the current status. Query the current status of the service.
Service Configuration Management sc config Modify the configuration of the service. Modify the service startup type, dependencies and other configurations.
sc description Modify the service description information. Update the service description field.
sc failure Processing behavior after configuration service failure. Set the recovery policy when the service fails (such as restarting the service, etc.).
sc failureflag Sets the processing flag when the service fails. Control actions after service failure.
sc sidtype Modify the SID type of the service. Configure the security identifier (SID) of the service.
sc privs Set permissions for the service. Configure the specific permissions required for the service to run.
sc managedaccount Configure the service account as the management password. Configure the service as an account managed by LSA.
Service query command sc qc Query the configuration information of the service. Displays the configuration information of the service, such as startup type, dependencies, etc.
sc qdescription Query the service description information. Returns the description of the service.
sc qfailure The failed handling strategy for querying the service. Returns the failed recovery policy for the service.
sc qfailureflag The failed flag of query service. Shows the service's failure flag.
sc qsidtype Query the SID type of the service. Query the security identifier (SID) of the service.
sc qprivs Query the permission configuration of the service. Returns the permission requirements for the service.
sc qtriggerinfo Query the trigger information of the service. Displays the trigger conditions and events of the service.
sc qpreferrednode The preferred NUMA node for query services. Displays the preferred NUMA node information used by the service.
sc qmanagedaccount Query whether the service uses an account managed by LSA. Check whether the service uses a password managed by the LSA.
sc qprotection Query the process protection level of the service. Returns the service's process protection information.
sc quserservice Query the user service template instance. Returns template instance information related to user service.
Service Deletion and Creation sc delete Delete the specified service. Delete the service from the service manager and cannot be restored.
sc create Create a new service. Create a new service and add it to the Service Manager.
Service Control sc control Send a control request to the service. Allows users to send specific control commands to the service, such as pause, continue, etc.
Service security management sc sdshow Displays the security descriptor for the service. Displays the permission settings and security description information of the service.
sc sdset Sets the security descriptor for the service. Modify the security permissions and access control list (ACL) of the service.
Service information and identification sc showsid Displays the SID (service identifier) ​​of the service. Displays the SID string corresponding to the service.
sc triggerinfo Configure or query service trigger parameters. Configure the trigger events and parameters of the service.
sc preferrednode The preferred NUMA node for configuration services. Sets the service's running preferences on NUMA nodes.
sc GetDisplayName Gets the display name of the service. Query the DisplayName information for the service.
sc GetKeyName Gets the service key name of the service. Query the service's registry key name.
sc EnumDepend Enumerate and display the service's dependencies. Query other services that the service depends on.
System configuration management sc boot Specifies whether to save the last startup as "Last known good configuration". Configure recovery options when system starts.
Service Database Management sc Lock Lock the service database. Prevent modifications to the service database.
sc QueryLock Query the locked status of the service database. Query whether the current service database is locked.

Functional classification summary

  • Service query and status management: Involves querying the status, extension information, display description, etc. of the service.
  • Service operation management: Used to start, stop, pause, restore services and other operations.
  • Service Configuration Management: Used to modify the configuration, description, failure policy, permissions, etc. of the service.
  • Service query command: Query the various configuration information, permissions, trigger conditions, etc. of the service.
  • Service Deletion and Creation: Including creating and deleting services and managing service life cycle.
  • Service security management: Modify or query the security descriptors (ACLs) and permission settings of the service.
  • System configuration management: Manage configuration options when system starts.
  • Service Database Management: Lock the service database or query the lock status to prevent modifications to the service.

This detailed table showsSCThe command line tools are widely used in Windows systems, covering all aspects of service management, from query, operation, configuration to security management and other functional categories.

The Windows SC (Service Control) command is a command-line tool used to interact with Windows services. It allows users to perform various actions such as starting, stopping, pausing, continuing, and configuring services. SC commands provide a convenient way to manage services running in the operating system, which are background programs that can be automatically started when Windows starts and run in the background as services when the system runs.

Using the SC command, the user can perform the following operations:

Start, stop and suspend services: The running services can be started, stopped and suspended through SC commands.

Query service status: You can use SC commands to query the status of the service, including whether it is running, stopped or suspended, etc.

Configure service parameters: You can use SC commands to configure various parameters of the service, such as startup type, service dependencies, service description, etc.

Manage service dependencies: You can use the SC command to add, delete, or display the dependencies of the service.

Other operations: The SC command also provides some other functions, such as locking the service database, querying the service lock status, etc.

SC commands are particularly useful for system administrators and advanced users because they allow them to easily perform various service management operations in a command-line environment without relying on a graphical user interface.

The Windows SC (Service Control) command originated from the Microsoft Windows operating system. It is developed to provide a convenient way to manage Windows services. Windows services are programs that run in the background. They can automatically start when the system starts and provide various functions and services when the operating system runs.

Initially, Windows services management was usually done through service management tools provided by graphical user interfaces (GUIs), such as Services Manager. However, as the demand and usage of the command line increased, Microsoft decided to provide a command line tool to perform service-related operations.

Therefore, Windows SC commands came into being, which provide administrators and advanced users with a way to manage Windows services in a command-line environment. SC commands can perform various operations through simple command line parameters, such as starting, stopping, pausing services, querying service status, configuring service parameters, etc.

The origin of the Windows SC command can be traced back to earlier versions of Windows operating systems such as the Windows NT series. As the Windows operating system continues to evolve and update, SC commands are also constantly improved and expanded to adapt to new features and needs. Until now, SC commands are still one of the main command line tools used to manage services in Windows operating systems.

The Windows SC (Service Control) command has gone through several stages in its development, including the stages of functional enhancement, improvement and adaptation to new technologies. Here are some development stages of Windows SC command:

Initial version (Windows NT)

The initial version may have been introduced in the Windows NT operating system for basic service management functions such as starting, stopping, and querying service status.

Functional enhancement

With the development of Windows operating systems, SC commands have gradually added more functions and options to provide richer service management capabilities. For example, functions such as configuring service parameters and managing service dependencies have been added.

Adapt to new technologies

With the update and introduction of new technologies in the Windows operating system, SC commands have also been updated and improved accordingly to meet the needs of new technologies. For example, the Windows Server operating system introduces new service types and features, and SC commands may support these new features accordingly.

Security enhancement

As the focus on system security continues to increase, SC commands may introduce more security features and options to ensure the security and reliability of service management operations.

Performance optimization

As computer system performance improves and efficiency requirements, SC commands may be performed to improve the execution speed and efficiency of service management operations.

Cross-platform support

As cloud computing and cross-platform technologies develop, SC commands may consider adding support for other operating system platforms to enable broader service management capabilities.

At each stage of development, Windows SC commands are constantly improving and evolving to meet changing needs and technological environments. This makes it one of the important management tools in the Windows operating system, providing convenient and powerful service management functions for administrators and advanced users.

The Windows SC (Service Control) command has a variety of application scenarios in the Windows operating system, mainly used to manage Windows services. Here are some common application scenarios:

Start and stop service

Use the SC command to easily start and stop a specified Windows service. This is useful for situations where manual control of service status is required, such as during troubleshooting or maintenance.

Query service status

Through the SC command, the current status of the specified service can be queried, such as running, stopped or suspended, etc. This helps to understand the health of each service in the system.

Suspend and continue services

The SC command can suspend and continue the specified service. This is useful when you need to temporarily abort the service to perform certain operations or debug problems.

Configuration Service

SC commands can be used to configure the service's startup type, startup parameters, dependencies and other properties. This allows administrators to easily manage various settings of the service through the command line.

Manage service dependencies

SC commands can be used to manage dependencies between services, including adding, deleting, and querying service dependencies. This is important to ensure that the service is properly up and running the other services it depends on.

Event logs and alarms

Through the SC command, the service's event log and alert settings can be configured to promptly discover and resolve problems in the service operation.

Remote Management

SC commands can remotely manage Windows services over the network, which is very useful for remote server management and automation scripts.

The Windows SC (Service Control) command provides administrators and advanced users with a convenient, flexible and powerful way to manage Windows services, helping to ensure system stability and reliability.

The Windows SC (Service Control) command also has some advanced application scenarios that can be used for more complex service management and system management tasks. Here are some advanced application scenarios:

Service automation

Using SC commands combined with scripting languages ​​(such as batch scripts, PowerShell scripts, etc.) can realize automated management of services. Administrators can write scripts to regularly check and adjust service status, configuration, and even automatically handle failures or exceptions.

Service monitoring and alerting

Combined with monitoring tools or custom scripts, administrators can use SC commands to monitor the status of Windows services in real time, and set alert mechanisms and automatic response policies. This will promptly detect service operation abnormalities and take necessary measures to restore the service.

Service cluster management

In a Windows Server environment, administrators may configure service clusters to improve availability and fault tolerance. SC commands can be used to manage services in service clusters, including failover, resource scheduling and other operations.

Service security management

Through SC commands, administrators can configure security permissions for services, limit access to services, and ensure security and reliability of services. This is very important to prevent malicious operations or unauthorized access.

Service performance optimization

Administrators can use SC commands to monitor and adjust the performance parameters of the service to optimize the performance and resource utilization of the service. This can be achieved by adjusting the service startup type, resource quota, etc.

Cross-platform management

SC commands can also be used for cross-platform management, such as managing remote Windows servers through Windows Remote Management Service (WinRM), or managing Linux-based servers using protocols such as SSH.

System integration and automation process

In an enterprise environment, administrators can integrate SC commands into automated workflows to automate and standardize service management. This can be achieved by using automation tools, configuration management systems, etc.

The Windows SC (Service Control) command plays an important role in advanced application scenarios, providing administrators with powerful service management and system management tools to help them manage and maintain the Windows environment more efficiently.

SC is a command line program used to communicate with the service control manager and services.

usage:

sc <server> [command] [service name] <option1> <option2>...
The format of option <server> is "\ServerName".

You can get more help with the command by typing "sc [command]".

Order:

query: query the status of the service, or enumerate the status of the service type.
queryex: query the extended state of the service, or enumerate the status of the service type.
start: Start the service.
pause: Send a pause control request to the service.
interrogate: Send a query control request to the service.
continue: Send a continuing control request to the service.
stop: Send a stop request to the service.
config: Change the configuration of the service (persistence).
description: Change the description of the service.
failure: Changes the action taken by the service when it fails.
failureflag: Change the failed operation flag of the service.
sidtype: Change the service SID type of the service.
privs: Change the privileges required for the service.
managedaccount: Change the service to mark the service account password as managed by LSA.
qc: Query the configuration information of the service.
qdescription: Query the description of the service.
qfailure: The action taken by querying the service when it fails.
qfailureflag: The failed operation flag of query service.
qsidtype: Query the service SID type of the service.
qprivs: Query the privileges required for the service.
qtriggerinfo: Query the trigger parameters of the service.
qpreferrednode: The preferred NUMA node for query services.
qmanagedaccount: Query whether the service uses an account with a password managed by the LSA.
qprotection: Query the process protection level of the service.
quserservice: Query the local instance of the user service template.
delete: Delete the service (from the registry).
create: Create a service (add it to the registry).
control: Send control to the service.
sdshow: Displays the security descriptor for the service.
sdset: Set the security descriptor for the service.

showsid: Displays the service SID string corresponding to any name.
triggerinfo: configures the trigger parameters of the service.
preferrednode: Sets the preferred NUMA node for the service.
GetDisplayName: Get the display name of the service.
GetKeyName: Get the service key name of the service.
EnumDepend: Enumerate the dependencies of the service.
The following command does not require a service name:

sc <server> <command> <option>
boot: (ok | bad) Indicates whether the last startup was saved as the last known good startup configuration.
Lock: Lock the service database.
QueryLock: Query the locked status of the SCManager database.
Example:

sc start MyService

Query and query extension options:

If the query command is followed by the service name, the status of the service is returned. In this case, further options do not apply. If the query command is followed by a blank or one of the following options, the service is enumerated.
type=: The service type to enumerate (driver, service, userservice, all) (default = service).
state=: The service status (inactive, all) to be enumerated (default = active).
bufsize=: The size of the enumeration buffer (in bytes) (default = 4096).
ri=: The restore index number of the start enumeration (default = 0).
group=: The service group to enumerate (default = all groups).
Syntax example:

sc query: Enumerate the status of active services and drivers.
sc query eventlog: Displays the status of the eventlog service.
sc queryex eventlog: Displays the extended status of the eventlog service.
sc query type= driver: only enumerate active drivers.
sc query type= service: only enumerate Win32 services.
sc query state= all: enumerates all services and drivers.
sc query bufsize= 50: Enumerate using a 50-byte buffer.
sc query ri= 14: enumerate using recovery index= 14.
sc queryex group= "": Enumerate active services that do not belong to any group.
sc query type= interact: enumerates all interactive services.
sc query type= driver group= NDIS: Enumerate all NDIS drivers.

sc create /?

describe:
Create a service entry in the registry and service database.

usage:
sc <server> create [service name] [binPath= ] <option 1> <option 2>...

Options:
Note: The option name includes an equal sign.
There needs to be a space between the equal sign and the value.
type= <own|share|interact|kernel|filesys|rec|userown|usershare>
(Default = own)
start= <boot|system|auto|demand|disabled|delayed-auto>
(default = demand)
error= <normal|severe|critical|ignore>
(Default = normal)
binPath= <binary pathname to .exe file>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <dependencies (separated by / (slash))>
obj= <AccountName|ObjectName>
(Default = LocalSystem)
DisplayName= <display name>
password= <password>

sc control /?

describe:
Send a control code to a service.

usage:
sc <server> control [service name] <value>
<value> = user defined control code
<value> = <paramchange|netbindadd|netbindremove|netbindenable|netbinddisable>

See also sc stop, sc pause and other commands.

Some examples of Windows SC (Service Control) commands applied at different levels:

Primary Application:

Start a service

shellCopy Code

sc start &lt;service_name&gt;

For example: Start Print Spooler service:sc start Spooler

Stop a service

shellCopy Code

sc stop &lt;service_name&gt;

For example: Stop Print Spooler service:sc stop Spooler

Query the status of a service

shellCopy Code

sc query &lt;service_name&gt;

For example: Query the status of the Print Spooler service:sc query Spooler

Intermediate application:

Configure the service startup type

shellCopy Code

sc config &lt;service_name&gt; start= &lt;start_type&gt;

For example: Set the startup type of the Print Spooler service to start automatically:sc config Spooler start= auto

Suspend and continue a service

shellCopy Code

sc pause &lt;service_name&gt;
sc continue &lt;service_name&gt;

For example: Suspend and continue Print Spooler service:sc pause Spoolersc continue Spooler

Delete a service

shellCopy Code

sc delete &lt;service_name&gt;

For example: Delete Print Spooler service:sc delete Spooler

Advanced applications:

Configure the dependencies of the service

shellCopy Code

sc config &lt;service_name&gt; depend= &lt;dependencies&gt;

For example: Setting up Print Spooler service depends on the Remote Procedure Call service:sc config Spooler depend= RPCSS

Query the configuration information of the specified service

shellCopy Code

sc qc &lt;service_name&gt;

For example: Query the configuration information of the Print Spooler service:sc qc Spooler

Create a new service

shellCopy Code

sc create &lt;service_name&gt; binPath= &lt;executable_path&gt;

For example: Create a service named MyService, with the executable file path C:\Path\To\:sc create MyService binPath= "C:\Path\To\"

Configure security permissions for services

shellCopy Code

sc sdset &lt;service_name&gt; &lt;security_descriptor&gt;

For example: Configure security permissions for Print Spooler service:sc sdset Spooler "D:(A;;CC;;;AU)(A;;CCLCRPRC;;;IU)(A;;CCLCRPRC;;;SU)(A;;CCLCRPWPRC;;;SY)(A;;KA;;;BA)(A;;CC;;;AC)S:(AU;FA;KA;;;WD)(AU;OIIOFA;GA;;;WD)"

These examples show how SC commands are applied at different levels. Primary applications mainly involve basic startup, stop and query service operations, intermediate applications involve some attributes and states of configuration services, while advanced applications involve more complex operations, such as configuration dependencies, security permissions, etc.

Some primary, intermediate and advanced application examples of Windows SC (Service Control) commands combined with other commands:

Primary Application:

Start and stop services in batches using batch scripts

Create a batch script with multiple SC commands to batch manage the start and stop of multiple services.

Implement scheduled service in conjunction with task planning

Use the Windows Task Scheduler in conjunction with SC commands to start or stop specific services regularly to achieve regular maintenance or tasks.

Intermediate application:

Combined with PowerShell scripts to implement service status monitoring

Write a PowerShell script, use SC commands to query the service status, and perform corresponding operations based on the status, such as sending email notifications or logging.

Use SC commands to combine system event logs to achieve service failure monitoring

Set up Windows event log to track events related to the service, then use the SC command to query the service status, and determine whether the service has failed based on the records in the event log, and then take corresponding measures.

Advanced applications:

Combining PowerShell scripts and SC commands to achieve automatic service recovery

Write a PowerShell script to check the service status regularly. If the service is found to be stopped, use the SC command to automatically start the service to achieve automatic recovery of the service.

Integrate with third-party monitoring tools for service management and alerting

Integrate SC commands with third-party monitoring tools (such as Nagios, Zabbix, etc.) to achieve real-time monitoring, alerting and automated processing of service status.

Combining configuration management tools to realize automated service configuration management

Use SC commands combined with configuration management tools (such as Ansible, Puppet, etc.) to realize the automated management and deployment of service configuration to ensure the consistency and reliability of service configuration.

These combinations and fit examples show how SC commands are applied in combination with other commands, scripts, or tools at different levels. In this way, administrators can manage and maintain Windows services more flexibly and efficiently.

Elementary, intermediate and advanced application examples of the Windows SC (Service Control) command combined with some other commands:

Primary Application:

Detect whether the service is available in combination with PING commands

Use the SC command to query the service status. If the service is in operation, use the PING command to check whether the host on which the service is located is reachable.

Combined with NET commands to view service-related network ports

Use the SC command to query the service's details, and then use the NETSTAT command to view the network port occupied by the service to ensure that the service is running properly and listen on the correct port.

Intermediate application:

In combination with the TASKLIST command, monitor the process where the service is located

Use the SC command to query the service status, and then use the TASKLIST command to view the processes associated with the service to monitor the service's operation and resource usage.

Event logs related to the combined viewing service

Use the SC command to query the service status and then query the event logs associated with the service in conjunction with the script to check the service's health and possible error information.

Advanced applications:

Remote query of service status combined with WMIC commands

Use WMIC commands combined with SC commands to realize query and management of service status on remote computers, so as to remotely monitor and manage services.

Combining PowerShell scripts and SC commands to achieve automated service management

Write a PowerShell script, combined with SC commands, to realize automated management of multiple services, including regular checking of service status, automatic start or stopping of services, etc.

These combined examples show different levels of scenarios in which SC commands are applied in combination with other commands. In this way, administrators can manage and monitor Windows services more flexibly and efficiently.

Examples of the SC create command in primary, intermediate and advanced applications:

Primary Application:

Create a basic custom service

sc create MyService binPath= "C:\Path\To\"

usesc createThe command creates a basic service, specifying the service name and the path to the executable file to be executed.

Intermediate application:

Create a service with custom descriptions and dependencies

sc create MyService binPath= "C:\Path\To\" DisplayName= "My Custom Service" depend= RpcSs/Afd

usesc createCommands create a service with custom descriptions and dependencies to better identify and manage services.

Advanced applications:

Create a service that runs with a specific user account

sc create MyService binPath= "C:\Path\To\" obj= "Domain\User" password= "Password"

usesc createCommands create a service and configure it to run under a specific user account for enhanced security.

Create a service with specific startup type and error control

sc create MyService binPath= "C:\Path\To\" start= auto error= severe

usesc createThe command creates a service and sets its startup type and error controls to ensure that it starts automatically when the system starts and can handle errors.

These examples show some scenarios where the SC create command is applied at different levels. Depending on actual needs, other options and parameters can be further combined to create more complex and customized services.

Willsc createPrimary, intermediate, and advanced application examples used in combination with some other commands:

Primary Application:

Create and start a basic service

sc create MyService binPath= "C:\Path\To\"
sc start MyService

usesc createThe command creates a service and then usessc startCommand to start the service.

Intermediate application:

Create a service and set the startup type

sc create MyService binPath= "C:\Path\To\"
sc config MyService start= auto

usesc createCommand creates a service and usessc configThe command sets its startup type to automatic.

Advanced applications:

Create a service and add a service description

sc create MyService binPath= "C:\Path\To\"
sc description MyService "This service is responsible for..."

usesc createCommand creates a service and usessc descriptionCommand adds a service description.

Create a service and configure service dependencies

sc create MyService binPath= "C:\Path\To\"
sc config MyService depend= Service1/Service2

usesc createCommand creates a service and usessc configCommands to configure the service's dependencies.

These examples show how tosc createCommands are used in combination with other commands to create, configure, and manage services. Depending on your needs, different commands can be combined to implement more complex operations and management tasks.

Primary Application:

Create a service and set a startup delay

sc create MyService binPath= "C:\Path\To\"
sc config MyService start= delayed-auto

usesc createCommand creates a service and usessc configThe command sets the startup delay time.

Intermediate application:

Create and configure the service failed to restart

sc create MyService binPath= "C:\Path\To\"
sc failure MyService reset= 86400 actions= restart/5000/restart/60000/restart/120000

usesc createCommand creates a service and usessc failureThe failed restart policy for the command to configure the service.

Advanced applications:

Create a service and configure service access

sc create MyService binPath= "C:\Path\To\"
sc sdset MyService D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)

usesc createCommand creates a service and usessc sdsetCommands to configure the security descriptor for the service.

Create a service and enable remote management

sc create MyService binPath= "C:\Path\To\"
sc config MyService obj= "NT AUTHORITY\LocalService" password= ""

usesc createCommand creates a service and usessc configCommand enables the remote management function of the service.

These examples show how to apply at different levelssc createCommands are used in combination with other commands to create, configure, and manage services and showcase more advanced features application instances. Depending on actual needs, more commands and parameters can be further explored and combined to meet specific management and configuration needs.

Primary Application:

Create a service and configure service logging

sc create MyService binPath= "C:\Path\To\"
sc config MyService start= auto obj= LocalSystem DisplayName= "My Service" type= own error= normal depend= +Netman start= auto error= normal DisplayName= "My Service" obj= ".\LocalSystem"

usesc createCommand creates a service and usessc configCommand to configure the logging options for the service.

Intermediate application:

Create a service and set the service startup order

sc create ServiceA binPath= "C:\Path\To\" start= auto
sc create ServiceB binPath= "C:\Path\To\" start= auto
sc config ServiceA depend= ServiceB

usesc createCommand creates a service and usessc configThe command sets the order in which the service is started.

Advanced applications:

Create and configure the execution context of the service

sc create MyService binPath= "C:\Path\To\" type= own obj= ".\LocalSystem" DisplayName= "My Service"

usesc createCommand creates a service and usessc configThe command configures the execution context of the service.

Create a service and set up a service to start a failed operation

sc create MyService binPath= "C:\Path\To\"
sc failure MyService reset= 86400 actions= restart/60000/restart/60000/restart/60000

usesc createCommand creates a service and usessc failureThe command sets the operation when the service starts fails.

These examples provide more application scenarios, covering primary, intermediate and advanced levels of use. Further adjustments and customizations can be made according to specific circumstances and needs.