Windows SC command details

Source: Internet
Author: User
Sccommand command details (a very useful Commander serves as a command line tool. SC .exe can be used to test your own system. You can set a batch file to use different parameters to call SC .exe to control the service. I. 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 can be selected: You can use Double Oblique lines, such as \ myserver, or \ 192.168.1.223 to operate remote computers. If you operate on a local computer, you do not need to add any parameters. The commands that SC can use are listed below. Config changes the configuration of a service. (Long term) Continue sends a request for continuous control over a service. Control sends a control to a service. Create creates a service. (Added to the Registry) delete a service. (Delete from the Registry) enumdepend lists the service subordination. Getdisplayname gets the display name of a service. Getkeyname gets the service key name of a service. Interrogate sends a query control request to a service. Pause sends a suspend control request to a service. QC asks about the configuration of a service. Query queries the status of a service. You can also list the status types of the service. Start starts a service. A stop request sends a stop request to a service. The name specified by servicename in the registry for the service key. Note that this name is different from the display name (this name can be seen in the Net start and Service Control Panel), and SC uses the service key name to identify the service. The optionname and optionvalues parameters allow you to specify the name and value of the operation command parameters. Note that there is no space between the operation name and the equal sign. 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. Set optionvalues to the value of the optionname parameter. The range of valid values is usually limited to the optionname parameter. To list each command, use SC command. Many comments commands require administrator permissions, so I would like to say that the Administrator is the best when you operate 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 get a detailed list of the commands. For example, you can enter SC create to obtain a list related to create. Except one command, SC query, this will export all the services and drivers currently running in the system. Program . 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. II. The SC CREATE command can create an entry in the Registry and service control management database. Syntax 1 SC [servername] Create servicename [optionname = optionvalues] servername, servicename, optionname, and optionvalues are the same as those above. Here we will detail the optionname and optionvalues. Optionname optionvalues description type = own, share, interact, kernel, filesys about the type of the service to be created. The option value includes the type used by the driver. The default value is share. Start = boot, system, auto, demand, and disabled. The options include the type used by the driver. The default value is demand (Manual ). Error = normal, severe, critical, and ignore when the service fails to import, the default value is normal. Binpath = (string) indicates the path name of the Service binary file. No default value exists. This string must be set. Group = (string) the group to which the 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 label. The default value is nothing depend = (space separated string. The name or group of the service that must be started before the service starts. OBJ = (string) the name used for account running. It can also be called the login identity. 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 is used if an account is different from the LocalSystem account. Value List of the optionname parameter. Refer to optionname. When we enter a string, if we enter an empty reference, this means that an empty string will be imported. Comments the SC create Command performs the operations of the createservice API function. This SC CREATE Command executes the createservice API function operation. For details, see createservice. Example 1 the following example creates a registry registration for a service named "mirror" on a computer. It runs the service automatically and belongs to the TDI group and NetBIOS service. C: \ windows \ system32 & gt; SC create mirror binpath = "D: \ FTP \ New Folder \ cmd.exe "type = own start = auto [SC] createservice success takes effect after restart Example 2 delete mirror service c: \ windows \ system32 & gt; SC Delete mirror binpath = "D: \ FTP \ New Folder \ cmd.exe" type = own start = auto [SC] deleteservice success III. SC qc: The SC QC "ask for 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 been described earlier. Buffersize, which can be used to list the buffer size. The comments 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 zookeeper extends lploadordergroup tag dwtagid display_name depends dependencies when service_start_name lpservicestartname Example 1 the following example describes the configuration of the "mirror" service created in the preceding example: SC qc SC displays the following information: SERVICE_NAME: mirror type: 10 win32_own_process start_type: 2 auto_start error_control: 1 normal Bina Ry_path_name: D: \ FTP \ load_order_group: Tag: 0 display_name: Mirror dependencies: service_start_name: LocalSystem mirror has the ability to share a process with other services. This service does not rely on other services and runs in the security relationship of lcoalsystem. These are basic responses for calling queryservicestatus. If you need more details, you can look at the API function file. Mirror IV. SC query command to obtain service information. Syntax: SC [servername] query {servicename | ptionname = optionvalues...} parameter: servername, servicename, optionname, optionvalues is not explained. 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, and all. The default value is active bufsize = (numeric values) the size of the list buffer. The default value is 1024 bytes rI = (numeric values). However, when the list is started, the number of the restore pointer is 0 optionvalues by default. The commentssc query command displays the service_status structure. The following figure shows the service_status structure: Type dwservicetype state dwcurrentstate, dwcontrolsaccepted using dwwin32exitcode service_exit_code implements checkpoint dwcheckpoint wait_hint dwwaithint. after starting the computer, the SC query command will tell you whether or not, or it is not an attempt to start the service. If the service is successfully started, the win32_exit_code interval will contain a value of 0. When the attempt fails, it realizes that the service cannot be started, this interval also provides an exit code for the service. For example, to query the "mirror" service status, type: SC query mirror to display the following information: SERVICE_NAME: mirror type: 10 win32_own_process state: 1 stopped (not_stoppable, not_pausable, ignores_shutdown win32_exit: 0 (0x0) service_exit_code: 0 (0x0) checkpoint: 0x0 wait_hint: 0x0 note that there is an exit code for this service, even if this service department is not running, type net helpmsg 1077 and you will receive a description of the 1077 error message: the service has not been started yet. So here I want to say that we hope you can use net helpmsg, which will be of great help to your learning. The following describes the SC query command: lists the status of the active service and driver. Run the following command: SC query to display the Messenger Service: SC query messenger only lists active drivers. Run the following command: SC Query type = driver to list Win32 services. Run the following command: SC Query type = service to list all services and drivers, run the following command: SC query state = all to list with a buffer of 50 bytes. Run the following command: SC query bufsize = 50 to use index = 14 when restoring the list. Run the following command: SC query rI = 14 lists all interactive services. Run the following command: SC Query type = service type = interact v. SC command to start Disabled Services, for example: start the telnet service SC config TlntSvr start = AutoNet start TlntSvr

Related Article

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.