SC command (Windows service on/off)

Source: Internet
Author: User

sc.exe command Feature List:

1. Change the startup status of the service (this is a useful feature)

2. Delete a service (unless you have a clear understanding of the software and hardware requirements of your computer, it is not recommended to remove any system services, especially basic services)

3. Stop or start the service (functionally similar to net Stop/start, but faster and can stop the service more)

The specific command format is as follows:

The command line format for modifying the service startup type is (especially note that there is a space behind start=)

 SC config Service name start= demand (set service to start manually)

sc config service name start= disabled (set service to Disabled)

The command-line format for the stop/start service is

SC Stop/start Service Name

Note: Usually contact is the display name of the service, and the above refers to the service name, can be in the Control Panel, management tools, services, double-click the corresponding service to query.

First illustrate the specific setup method:

If the Remote Registry service is set to a manual format of

sc config RemoteRegistry start= demand

The formats that are set to Disabled are:

sc config remoteregistry start= disabled

Stop service The format is:

sc stop RemoteRegistry

First, you need to set the name of the service to find out, in accordance with the format of the batch file, re-install the system as long as the batch file can be run.

Here are my settings, based on XPSP2, can be compared to the system used to delete and modify. Note: XPSP2 Automatic Updates, Security Center, firewall are not joined.

sc config Alerter start= demand

sc config Trkwks start= demand

sc config helpsvc start= demand

sc config PolicyAgent start= demand

sc config Dmserver start= demand

sc config wmdmpmsn start= demand

sc config Spooler start= demand

sc config RemoteRegistry start= demand

sc config ntmssvc start= demand

sc config Seclogon start= demand

sc config Schedule start= demand

sc config WebClient start= demand

sc config W32Time start= demand

sc config WZCSVC start= demand

sc config ersvc start= demand

sc config Themes start= demand

sc config fastuserswitchingcompatibility start= disabled

sc config Messenger start= disabled

sc config protectedstorage start= disabled

sc config ssdpsrv start= disabled

sc config TermService start= disabled

sc config shellhwdetection start= disabled

If you need to close the service immediately, you can follow the code below

sc stop W32Time

sc stop ShellHWDetection

sc stop Trkwks

sc stop helpsvc

sc stop Dmserver

sc stop PolicyAgent

sc stop Spooler

sc stop remoteregistry; remotely modify the registry

sc stop Seclogon

sc stop Schedule

sc stop WZCSVC

sc stop Ersvc

sc stop Themes

sc stop fastuserswitchingcompatibility

sc stop ProtectedStorage

sc stop SSDPSRV

sc stop WebClient

Finally, the modified code saved as Services.cmd, in the future service settings, directly run the pre-saved batch files can be done with less effort.

See here, the use of Win2000 friends do not have to be disappointed, Sc.exeThis command-line tool is also suitable for Win2000, which can be copied from a machine equipped with WinXP or Win2003 Sc.exeFile, put it together with the saved batch file, and then execute the batch file.

A friend who is familiar with the registry may think of using the registry to set the startup type of the service, which is a viable approach, but inherently inadequate. The reason is that the service startup type has a long and dispersed key value in the registry, and it is easy to collate and error-prone, so this method is more suitable for unattended installations.
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.