SCCommunicates with the Service Controller and installed services. SC.exe retrieves and sets control information about services. You can use SC.exe for testing and debugging service programs. Service properties stored in the registry can be set to control how service applications are started at boot time and run as background processes. SC.exe parameters can configure a specific service, retrieve the current status of a service, as well as stop and start a service. You can create batch files that call various SC.exe commands to automate the startup or shutdown sequence of services. SC.exe provides capabilities similar to Services in the Administrative Tools item in Control Panel. For the command syntax, click any of the following sc commands: sc boot Indicates whether the last boot should be saved as the last-known-good configuration. Syntaxsc [ServerName] boot [{bad|OK}] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the Universal Naming Convention (UNC) format ("\\myserver"). To run SC.exe locally, ignore this parameter. [{bad|OK}] : Specifies whether the last boot was bad or whether it should be saved as the last-known-good boot configuration. /?: Displays help at the command prompt. ExamplesThe following examples show how you can use the sc boot command: sc boot ok sc config Modifies the value of a service's entries in the registry and in the Service Control Manager's database. Syntaxsc [ServerName] config [ServiceName] [type= {own|share|kernel|filesys|rec|adapt|interact type= {own|share}}] [start= {boot|system|auto|demand|disabled}] [error= {normal|severe|critical|ignore}] [binpath= BinaryPathName] [group= LoadOrderGroup] [tag= {yes|no}] [depend= dependencies] [obj= {AccountName|ObjectName}] [displayname= DisplayName] [password= Password] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the Universal Naming Convention (UNC) format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. type= {own|share|kernel|filesys|rec|adapt|interact type= {own|share}} : Specifies the service type.
start= {boot|system|auto|demand|disabled} : Specifies the start type for the service.
error= {normal|severe|critical|ignore} : Specifies the severity of the error if the service fails to start during boot.
binpath= BinaryPathName : Specifies a path to the service binary file. group= LoadOrderGroup : Specifies the name of the group of which this service is a member. The list of groups is stored in the registry in the HKLM\System\CurrentControlSet\Control\ServiceGroupOrder subkey. The default is null. tag= {yes|no} : Specifies whether or not to obtain a TagID from the CreateService call. Tags are only used for boot-start and system-start drivers. depend= dependencies : Specifies the names of services or groups which must start before this service. The names are separated by forward slashes (/). obj= {AccountName|ObjectName} : Specifies a name of an account in which a service will run, or specifies a name of the Windows driver object in which the driver will run. The default is LocalSystem. displayname= DisplayName : Specifies a friendly, meaningful name that can be used in user-interface programs to identify the service to users. For example, the subkey name of one service is wuauserv, which is not be helpful to the user, and the display name is Automatic Updates. password= Password : Specifies a password. This is required if an account other than the LocalSystem account is used. /?: Displays help at the command prompt. Remarks
ExamplesThe following example shows how you can use the sc config command: sc config NewService binpath= "ntsd -d c:\windows\system32\NewServ.exe" sc continue Sends a CONTINUE control request to a service in order to resume a paused service. Syntaxsc [ServerName] continue [ServiceName] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. /?: Displays help at the command prompt. Remarks
ExamplesThe following example shows how you can use the sc continue command: sc continue tapisrv sc control Sends a CONTROL B to a service. Syntaxsc [ServerName] control [ServiceName] [{paramchange|netbindadd|netbindremove|netbindenable|netbinddisable|UserDefinedControlB}] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. {paramchange|netbindadd|netbindremove|netbindenable|netbinddisable|UserDefinedControlB} : Specifies a control to send to a service. /?: Displays help at the command prompt. sc create Creates a subkey and entries for the service in the registry and in the Service Control Manager's database. Syntaxsc [ServerName] create [ServiceName] [type= {own|share|kernel|filesys|rec|adapt|interact type= {own|share}}] [start= {boot|system|auto|demand|disabled}] [error= {normal|severe|critical|ignore}] [binpath= BinaryPathName] [group= LoadOrderGroup] [tag= {yes|no}] [depend= dependencies] [obj= {AccountName|ObjectName}] [displayname= DisplayName] [password= Password] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. type= {own|share|kernel|filesys|rec|adapt|interact type= {own|share}} : Specifies the service type. The default is type= own.
start= {boot|system|auto|demand|disabled} : Specifies the start type for the service. The default start is start= demand.
error= {normal|severe|critical|ignore} : Specifies the severity of the error if the service fails to start during boot. The default is error= normal.
binpath= BinaryPathName : Specifies a path to the service binary file. There is no default for binpath= and this string must be supplied. group= LoadOrderGroup : Specifies the name of the group of which this service is a member. The list of groups is stored in the registry in the HKLM\System\CurrentControlSet\Control\ServiceGroupOrder subkey. The default is null. tag= {yes|no} : Specifies whether or not to obtain a TagID from the CreateService call. Tags are only used for boot-start and system-start drivers. depend= dependencies : Specifies the names of services or groups that must start before this service. The names are separated by forward slashes (/). obj= {AccountName|ObjectName} : Specifies a name of an account in which a service will run, or specifies a name of the Windows driver object in which the driver will run. displayname= DisplayName : Specifies a friendly name that can be used by user-interface programs to identify the service. password= Password : Specifies a password. This is required if an account other than LocalSystem is used. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc create command: sc \\myserver create NewService binpath= c:\windows\system32\NewServ.exe sc delete Deletes a service subkey from the registry. If the service is running or if another process has an open handle to the service, then the service is marked for deletion. Syntaxsc [ServerName] delete [ServiceName] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. /?: Displays help at the command prompt. Remarks
ExamplesThe following example shows how you can use the sc delete command: sc delete newserv sc description Sets the description string for a service. Syntaxsc [ServerName] description [ServiceName] [Description] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. Description : Specifies a description for the specified service. If no string is specified, the description of the service is not modified. There is no limit to the number of characters that can be contained in the service description. /?: Displays help at the command prompt. ExamplesThe following example shows how you can use the sc description command: sc description newserv "Runs quality of service control." sc enumdepend Lists the services that cannot run unless the specified service is running. Syntaxsc [ServerName] enumdepend [ServiceName] [BufferSize] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. BufferSize : Specifies the size (in bytes) of the enumeration buffer. The default is 1024 bytes. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc enumdepend command: sc enumdepend rpcss 5690 sc failure Specifies what action to take upon failure of the service. Syntaxsc [ServerName] failure [ServiceName] [reset= ErrorFreePeriod] [reboot= BroadcastMessage] [command= CommandLine] [actions= FailureActionsAndDelayTime] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. reset= ErrorFreePeriod : Specifies the length of the period (in seconds) with no failures after which the failure count should be reset to 0. This parameter must be used in conjunction with the actions= parameter. reboot= BroadcastMessage : Specifies the message to be broadcast upon failure of the service. command= CommandLine : Specifies the command line to be run upon failure of the service. For more information about how to run a batch or VBS file upon failure, see Remarks. actions= FailureActionsAndDelayTime : Specifies the failure actions and their delay time (in milliseconds) separated by the forward slash (/). The following actions are valid: run, restart, and reboot. This parameter must be used in conjunction with the reset= parameter. Use actions= "" to take no action upon failure. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc failure command: sc failure msftpsvc reset= 30 actions= restart/5000 sc getdisplayname Gets the display name associated with a particular service. Syntaxsc [ServerName] getdisplayname [ServiceName] [BufferSize] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. BufferSize : Specifies the size (in bytes) of the buffer. The default is 1024 bytes. /?: Displays help at the command prompt. ExamplesThe following examples show how you can use the sc getdisplayname command: sc getdisplayname clipsrv sc getkeyname Gets the key name associated with a particular service, using the display name as input. Syntaxsc [ServerName] getkeyname [ServiceDisplayName] [BufferSize] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceDisplayName : Specifies the display name of the service. BufferSize : Specifies the size (in bytes) of the buffer. The default is 1024 bytes. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc getkeyname command: sc getkeyname "remote procedure call (rpc)" sc interrogate Sends an INTERROGATE control request to a service. Syntaxsc [ServerName] interrogate [ServiceName] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc interrogate command: sc interrogate sharedaccess sc lock Locks the Service Control Manager's database. Syntaxsc [ServerName] lock ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. /?: Displays help at the command prompt. Remarks
ExamplesThe following example shows how you can use the sc lock command: sc lock sc pause Sends a PAUSE control request to a service. Syntaxsc [ServerName] pause [ServiceName] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. /?: Displays help at the command prompt. Remarks
ExamplesThe following example shows how you can use the sc pause command: sc pause tapisrv sc qc Queries the configuration information for a service. Syntaxsc [ServerName] qc [ServiceName] [BufferSize] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. BufferSize : Specifies the size (in bytes) of the buffer. The default is 1024 bytes. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc qc command: sc qc \\myserver newsrvice sc qdescription Displays the description string of a service. Syntaxsc [ServerName] qdescription [ServiceName] [BufferSize] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. BufferSize : Specifies the size (in bytes) of the buffer. The default is 1024 bytes. /?: Displays help at the command prompt. ExamplesThe following examples show how you can use the sc qdescription command: sc qdescription rpcss sc qfailure Displays the actions that will be performed if the specified service fails. Syntaxsc [ServerName] qfailure [ServiceName] [BufferSize] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. BufferSize : Specifies the size (in bytes) of the buffer. The default is 1024 bytes. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc qfailure command: sc qfailure rpcss sc query Obtains and displays information about the specified service, driver, type of service, or type of driver. Syntaxsc [ServerName] query [ServiceName] [type= {driver|service|all}] [type= {own|share|interact|kernel|filesys|rec|adapt}] [state= {active|inactive|all}] [bufsize= BufferSize] [ri= ResumeIndex] [group= GroupName] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. This query parameter is not used in conjunction with other query parameters (other than ServerName). type= {driver|service|all} : Specifies what to enumerate. The default type is service.
type= {own|share|interact|kernel|filesys|rec|adapt} : Specifies the type of services or type of drivers to enumerate.
state= {active|inactive|all} : Specifies the started state of the service for which to enumerate. The default state is active.
bufsize= BufferSize : Specifies the size (in bytes) of the enumeration buffer. The default size is 1024 bytes. Increase the size of the enumeration buffer when the display resulting from a query exceeds 1024 bytes. ri= ResumeIndex : Specifies the index number at which to begin or resume the enumeration. The default is 0. Use this parameter in conjunction with the bufsize= parameter when more information is returned by a query than the default buffer can display. group= GroupName : Specifies the service group to enumerate. The default is all groups. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc query command: sc query sc queryex Obtains and displays extended information about the specified service, driver, type of service, or type of driver. Syntaxsc [ServerName] queryex [type= {driver|service|all}] [type= {own|share|interact|kernel|filesys|rec|adapt}] [state= {active|inactive|all}] [bufsize= BufferSize] [ri= ResumeIndex] [group= GroupName] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. This queryex parameter is not used in conjunction with any other queryex parameters except ServerName. type= {driver|service|all} : Specifies what to enumerate. The default type is service.
type= {own|share|interact|kernel|filesys|rec|adapt} : Specifies the type of services or type of drivers to enumerate.
state= {active|inactive|all} : Specifies the started state of the service for which to enumerate. The default state is active.
bufsize= BufferSize : Specifies the size (in bytes) of the enumeration buffer. The default size is 1024 bytes. ri= ResumeIndex : Specifies the index number at which to begin or resume the enumeration. The default is 0. group= GroupName : Specifies the service group to enumerate. The default is all groups. /?: Displays help at the command prompt. Remarks
ExamplesThe following examples show how you can use the sc queryex command: sc queryex messenger sc querylock Queries and displays the lock status for the Service Control Manager's database. Syntaxsc [ServerName] querylock ParameterServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. /?: Displays help at the command prompt. sc sdset Sets a service's security descriptor using Service Descriptor Definition Language (SDDL). Syntaxsc [ServerName] sdset ServiceName ServiceSecurityDescriptor ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. ServiceSecurityDescriptor : Specifies the service descriptor in SDDL. /?: Displays help at the command prompt. Remarks
sc sdshow Displays a service's security descriptor using SDDL. Syntaxsc [ServerName] sdshow ServiceName ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. /?: Displays help at the command prompt. Remarks
Examplessc sdshow rpcss sc start Starts a service running. Syntaxsc [ServerName] start ServiceName [ServiceArguments] ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. ServiceArguments : Specifies service arguments to pass to the service to be started. /?: Displays help at the command prompt. ExamplesThe following example shows how you can use the sc start command: sc start tapisrv sc stop Sends a STOP control request to a service. Syntaxsc [ServerName] stop ServiceName ParametersServerName : Specifies the name of the remote server on which the service is located. The name must use the UNC format ("\\myserver"). To run SC.exe locally, ignore this parameter. ServiceName : Specifies the service name returned by the getkeyname operation. /?: Displays help at the command prompt. Remarks
ExamplesThe following example shows how you can use the sc stop command: sc stop tapisrv RemarksFormatting legend
|