Windows service command line management

Source: Internet
Author: User
Tags net command
Windows service management mainly uses two Commands: SC net, where SC can modify service attributes and other information, and can add or delete services:

 

# View the service creation Information

C:/Documents and Settings/sina>sc create
Creates a service entry in the registry and Service Database.
SYNTAX:
sc create [service name] [binPath= ] <option1> <option2>...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
 type= <own|share|interact|kernel|filesys|rec>
       (default = own)
 start= <boot|system|auto|demand|disabled>
       (default = demand)
 error= <normal|severe|critical|ignore>
       (default = normal)
 binPath= <BinaryPathName>
 group= <LoadOrderGroup>
 tag= <yes|no>
 depend= <Dependencies(separated by / (forward slash))>
 obj= <AccountName|ObjectName>
       (default = LocalSystem)
 DisplayName= <display name>
 password= <password>

C:/Documents and Settings/sina>

 

# Delete a service

sc delete servicename

# Start the service

sc start servicename

# Stop a service

sc stop servicename

# Query the status of all services

sc query

# Querying the status of a specified service

sc query servicename

 

# Querying service description

sc qdescription servicename

# Querying service configuration information

sc qc servicename

# Query the display name based on the service name

sc getdisplayname servicename

# Query the service name based on the display name

sc getkeyname displayname

# Modify service description

SC description servicename "Description"

# Modify more service configurations

SC config servicename displayname = "display name" type = ......

 

 

Note: SC operates on the service name (not the display name). For example, the Telnet display name is Telnet and the service name is TlntSvr.
SC start Telnet as follows:
SC start TlntSvr
SC:
SC stop TlntSvr

 

SC can modify the display name of a service, but cannot modify the service name. If the service name is complex, it may be difficult to write, but it cannot be modified. What should I do...

Use the net command. Net can operate the service name or service display name. If the service display name is complex, you can use SC to modify the display name, for example: the name of my apache service is very long: apmserve-Apache. It is troublesome to press it in the command, and the display name is also so long. Modify the display name:

 

sc config APMServe-Apache DisplayName= httpd

Note: spaces between httpd and equal signs must be available.

Now you can run the following command:

net start httpd
net stop httpd

Of course:
net start  APMServe-Apache
net stop  APMServe-Apache

Yes, too.

More Net Usage:

net /?

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.