Windows service operation-delete service batch implementation

Source: Internet
Author: User

Save the following characters as a batch file. bat Copy codeThe Code is as follows: echo is stopping the service...
Net stop TEST Service
Echo is deleting the service...
SC delete TEST Service
Echo press any key to exit...
Pause

SC help files can use SC /? Obtain
Error: Unknown command
Description:
SC is a command line program used to communicate with the Service Control Manager.
Usage:
SC <server> [command] [service name] <option1> <option2>...
The format of option <server> is \ ServerName"
You can type "SC [command]" for further help on the command.
Command:
Query ----------- query the service status,
Or enumerate the status of the service type.
Queryex --------- query the scaling status of a service,
Or enumerate the status of the service type.
Start ----------- start the service.
Pause ----------- send a PAUSE control request to the service.
Interrogate ----- send an INTERROGATE control request to the service.
Continue -------- send a CONTINUE control request to the service.
Stop ------------ send a STOP request to the service.
Config ---------- (permanently) change the service configuration.
Description ----- change the service description.
Failure --------- operation performed when the service fails to be changed.
Qc -------------- query service configuration information.
Qdescription ---- query the service description.
Qfailure -------- query the operation performed by the failed service.
Delete ---------- delete a service from the registry.
Create ---------- create a service (add it to the registry ).
Control --------- send control to service.
Sdshow ---------- display the service security descriptor.
Sdset ----------- set the service security descriptor.
GetDisplayName -- get the DisplayName of the service.
GetKeyName ------ get the ServiceKeyName of the service.
EnumDepend ------ enumerate service dependencies.
The following command does not query the service name:
SC <server> <command> <option>
Boot ------------ (OK | bad) indicates whether to save the last startup
The last known STARTUP configuration
Lock ------------ Lock the Service Database
QueryLock ------- query the LockStatus of the SCManager Database
Example:
SC start MyService
Do you want to see the help of the QUERY and QUERYEX commands? [Y | n]:
QUERY and QUERYEX options:
If the query command contains a service name
The status of the service. Other options are not suitable for this type
Status. If the query command does not contain parameters or
This service is enumerated with one of the following options.
Type = type of the service to be enumerated (driver, service, all)
= Service by default)
State = the status of the service to be enumerated (inactive, all)
(Default = active) \ n"
Bufsize = enumeration buffer size (in bytes)
(Default = 4096)
Ri = recovery index number \ n "for start Enumeration"
(Default = 0)
Group = Service group to be enumerated
(Default = all groups)
Syntax example
SC query-enumerative status of active services and drivers
SC query messenger-displays the status of the messenger Service
SC queryex messenger-displays the extended status of the messenger Service
SC query type = driver-only enumeration of active drivers
SC query type = service-only enumerate Win32 services
SC query state = all-enumerate all services and drivers
SC query bufsize = 50-enumeration buffer is 50 bytes
SC query ri = 14-index Restoration during enumeration = 14
SC queryex group = \ "\"-enumeration of activity services not in the group
SC query type = service type = interact-enumerate all inactive services
SC query type = driver group = NDIS-enumerate all NDIS drivers

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.