To start a service using the command line

Source: Internet
Author: User
Click to open the link

To start a service using the command line
Under CMD There are two ways to open, net and sc,net to open services that are not disabled, and the syntax is:
Net start Service name start net start service name
Stopping net stop service name
NET stop service Name
A disabled service can be opened with SC, and the syntax is:
sc Config Service name start= demand//Manual
SC condig Service name start= Auto//Auto
sc config service name start= disabled//disabled
SC Start service Name
sc stop service Name
Note: 1 service name is not necessarily the name you see in the service panel, for example, you want to open the disabled Telnet service, sc config telnet start= auto, error: [SC] OpenService FAILED   1060, because the service name of Telnet is not telnet but tlntsvr, sc config tlntsvr start= Auto is OK, look up the Telnet property in the service panel, see the service program name from the path of the executable file, namely the service name in the command. 2 start= behind a space, less is wrong
Sc.exe command Feature List: NOTE: in the following command. The = number has a space behind it, and the = number is preceded by a space.

1. Change the startup status of the service (this is a useful feature)
2. Delete Service (unless the hardware and software required for your own computer is clearer, it is not recommended to remove any system services, especially basic services)
3. Stop or start the service (features similar to net Stop/start, but faster and can stop the service more)
The specific command format is as follows:
Modify the command line format for the service startup type (pay special attention to a space after 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, give an example of how to set up a specific method:
such as setting the remote Registry service to manually its format as
sc config RemoteRegistry start= demand
The format that you set as disabled is:
sc config remoteregistry start= disabled
The stop service is formatted as:
sc stop RemoteRegistry
First of all, you need to set the service name to find out, according to the format of the batch processing file, after reloading the system as long as the run batch file.
Here are my settings, based on XPSP2, can be compared to the use of the system to delete and modify. Note: No Automatic Updates, security centers, firewalls are added to the XPSP2.
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 shut down 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
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 to save as Services.cmd, in the future when the service settings, directly run a saved batch file can be done with less effort.
See here, use Win2000 Friend also not to be disappointed, Sc.exe This command-line tool is also suitable for Win2000, can copy Win2003 file from the machine containing WinXP or Sc.exe, put together with the saved batch file, then execute batch file.
A friend who is familiar with the registry might think of setting up the service's startup type with the registry, which is a viable method, but inherently inadequate. The reason is that the service startup type in the registry for the corresponding key value is longer and dispersed, the collation is not easy to intuitive and error-prone, so this method is more suitable for unattended installation use.
Use case:
To start the Automatic Updates service at the command line:
C:\>SC config wuauserv start= Auto
[SC] Changeserviceconfig SUCCESS
C:\>SC start wuauserv
Service_name:wuauserv
Type:20 win32_share_process
State:2 start_pending
(Not_stoppable,not_pausable,ignores_shutdown)
win32_exit_code:0 (0x0)
service_exit_code:0 (0x0)
checkpoint:0x0
Wait_hint:0x7d0
pid:1156
FLAGS:
C:\>

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.