SC command details

Source: Internet
Author: User
By calling the Windows SC command, you can add or delete a service in a Windows service or configure the corresponding service to automatically start the application. The following describes how to use the collected SC commands:
SC uses the following syntax:
1. SC [servername] command servicename [optionname = optionvalues]
2. SC [command]
The first syntax uses SC and the second syntax displays help.
The following describes the parameters.
Servername
Optional: You can use double slashes, such as /// myserver or //// 192.168.0.1 to operate the remote computer. If you operate on a local computer
You do not need to add any parameters.
Command
The following lists the SC commands that can be used.
Config ---- change the configuration of a service. (Long term)
Continue -- send a request for continuous control to a service.
Control ---- send a control to a service.
Create ---- create a service. (Add to Registry)
Delete ---- delete a service. (Delete from Registry)
Enumdepend -- lists the service subordination.
Getdisplayname -- get the display name of a service.
Getkeyname -- get the service key name of a service.
Interrogate -- sends a query control request to a service.
Pause ---- send a suspend control request to a service.
QC ---- ask about the configuration of a service.
Query ---- query the status of a service. You can also list the status types of the service.
Start ---- start a service.
Stop ---- requests a service to send a stop request.
Servicename
Name specified for the service key in the registry. Note that this name is different from the display name (this name can be set using net start and service control.
And SC uses the service key name to identify the service.
Optionname
The optionname and optionvalues parameters allow you to specify the name and value of the operation command parameters. Note that this is important in terms of the operation name and
There is no space between them. I don't know the result at first .................., For example, start = optionvalues, which is very important.
Optionvalues can be 0, 1, or more operation parameter names and value pairs.
If you want to view the optionvalues available for each command, you can use the SC command format. This will provide you with detailed help.
Optionvalues
Specify a value for the parameter name of optionname. The range of valid values is usually limited to the optionname parameter. Use
SC command to query each command.
Comments
Many Commands require administrator permissions, so I would like to say that you should be the administrator when operating these commands. Haha!
When you click "SC .exe" without any commands, SC .exe displays help information and available commands. When you type SC followed by the command name, you can
To a detailed list of commands. For example, you can enter SC create to obtain a list related to create.
Except for one command, SC query exports the status of all services and drivers currently running in the system.
When you use the start command, you can pass some parameters (arguments) to the main function of the service, but not to the main function of the service process.
SC create
This command can be used to create an entry in the Registry and service control management database.
Syntax 1
SC [servername] Create servicename [optionname = optionvalues]
The servername, servicename, optionname, and optionvalues here are the same as those above. Here we will detail
Optionname and optionvalues.
Optionname -- optionvalues
Description
Type = ---- own, share, interact, kernel, filesys
About the service creation type, the option value includes the type used by the driver. The default value is share.
Start = ---- boot, sys tem, auto, demand, Disabled
About the Service Startup type, the option value includes the type used by the driver. The default value is demand (Manual ).
Error = ---- normal, severe, critical, ignore
The default value is normal.
Binpath = -- (string)
The path name of the Service binary file. There is no default value here. This string must be set.
Group = ---- (string)
The group to which this service belongs. The list of this group is saved under servicegrouporder in the registry. The default value is nothing.
Tag = ---- (string)
If this string is set to yes, SC can get a tagid from createservice call. However, SC does not display this label
It makes little sense to use this. The default value is nothing.
Depend = ---- (space separated string) string with spaces.
The name or group of the service that must be started before the service starts.
OBJ = ---- (string)
The name used for account running. The default value is localsys TEM.
Displayname = -- (string)
A string used to identify each service in the user interface program.
Password = -- (string)
A password, which must be used if it is used by a different account than localsys TEM.
Optionvalues
The Value List of the optionname parameter. Refer to optionname. When we input a string, If we input an empty reference, this means
An empty string will be imported.
Comments
The SC CREATE Command performs the operations of the createservice API function.
Run the SC CREATE command to execute the createservice API function. For details, see createservice.
Example 1
The following example shows how to register a registry created for a service named "newservice" on a computer called (// myserver.
SC /// myserver create newservice binpath = C: // winnt // sys tem32 // newserv.exe
By default, this service creates a win32_assist_process startup mode using service_demand_start. This will not have any subordination
And runs according to the localsys TEM security up-down relationship.
Example 2
In the following example, a service is created on a local computer and runs on its own process automatically. It
From the TDI group and NetBIOS service. Note that you must add a space reference to the slave.
SC create newservice binpath = C: // winnt // sys tem32 // newserv.exe type = own
Start = auto depend =/'+ tdi netbios /'
Example 3
Service developers can temporarily change the binary path (image path) to run the service in the context of the kernel debugger. Lower
In this example, we can see how to change the service configuration.
SC config newservice binpath =/'ntsd-D C: // winnt // sys tem32 // newserv.exe /'
In this example, the service controller calls ntsd.exe to use the following parameter string:
/'-D c: // nt // sys tem32 // newserv.exe /'
When the system is installed with newserv.exe, ntsd will interrupt the debugger, so the breakpoint can be set in the service code.
SC QC
This SC QC "query configuration" command can list the configuration information of a service and the query_service_config structure.
Syntax 1
SC [servername] QC servicename [buffersize]
Parameters
Servername and servicename have already been introduced.
Buffersize, which can be used to list the buffer size.
Comments
The SC QC command displays the content of the query_service_config structure.
The following is the region of query_service_config.
Type ------ dwservicetype
Start_type ---- dwstarttype
Error_control ---- dwerrorcontrol
Binary_path_name -- lpbinarypathname
Load_order_group -- lploadordergroup
Tag ------ dwtagid
Display_name ---- lpdisplayname
Dependencies ---- lpdependencies
Service_start_name -- lpservicestartname
Example 1
The following example shows the configuration of the "newservice" service created in the preceding example:
SC /// myserver QC newservice
SC displays the following information:
SERVICE_NAME: newservice
Type: 20 win32_0000_process
Start_type: 3 demand_start
Error_control: 1 normal
Binary_path_name: C: // winnt // sys tem32 // newserv.exe
Load_order_group:
Tag: 0
Display_name: newservice
Dependencies:
Service_start_name: localsys TEM
Newservice can share a process with other services. But it is not automatically started. The binary file name is newserv.exe. This service
It does not rely on other services and runs in the secure upper/lower relationship of lcoalsys TEM. These are basic responses to queryservicestatus.
Back, if you need more details, you can look at the API function file.
SC Query
The SC query command can obtain service information.
Syntax:
SC [servername] query {servicename | optionname = optionvalues ...}
Parameters:
Servername, servicename, optionname, and optionvalues are not interpreted. Let's just talk about the value provided by this command.
Optionname -- optionvalues
Description
Type = ---- driver, service, all
Lists the service types. The default value is service.
State = ---- active, inactive, all
Lists the status of a Service. The default value is active.
Bufsize = -- (numeric values)
List Buffers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.