Windows Service Operation Removal Service batch implementation _dos/bat

Source: Internet
Author: User
Save the following characters as a batch file. bat
Copy Code code as follows:

echo is stopping service ...
NET stop test Service
echo is removing service ...
SC Delete Test Service
Echo Press any key to exit ...
Pause

SC Help file can use SC/? Get
Error: Unknown command
Describe:
SC is a command-line program used to communicate with the Service Control Manager.
Usage:
SC <server> [command] [service name] <option1> <option2>
The option <server> format is "\\ServerName"
You can type "sc [command]" to get further help for the command
Command:
Query-----------The state of the service,
Or enumerate the state of the service type.
Queryex---------The extended state of the query service,
Or enumerate the state of the service type.
Start-----------starting the service.
Pause-----------Send Pause control requests to the service.
Interrogate-----Send interrogate control requests to the service.
Continue--------send continue control requests to the service.
Stop------------send a stop request to the service.
Config----------(permanently) change the configuration of the service.
Description-----Change the description of the service.
Failure---------to change the operation when a service fails.
The QC--------------the configuration information for the query service.
Qdescription----The description of the query service.
Qfailure the operation--------the query failed service.
Delete----------(from the registry) to remove the service.
The Create----------creates a service (adds it to the registry).
Control---------send controls to the service.
Sdshow----------Display the security descriptor for the service.
Sdset-----------Set the security descriptor for the service.
getdisplayname--gets the DisplayName of the service.
Getkeyname------Get the servicekeyname of the service.
EnumDepend------Enumerate the dependencies of the service.
The following command does not query the service name:
SC <server> <command> <option>
The boot------------(OK | bad) indicates whether the last boot was saved as
The last Known good boot configuration
Lock------------Locking Service database
Querylock-------Query The lockstatus of Scmanager database
Example:
SC start MyService
Do you want to check the Help for QUERY and QUERYEX commands? [y | n]:
QUERY and QUERYEX options:
If the query command takes a service name, it returns
The status of the service. Other options are not appropriate for this
Situation If the query command takes no parameters or
This service is enumerated with one of the following options.
Type= the type of service to enumerate (driver, service, all)
Default = Service)
State= the status of the service to enumerate (inactive, all)
(default = active) \ n "
Size of the Bufsize= enumeration buffer in bytes
(default = 4096)
ri= The recovery index number of the enumeration. \ n "
(default = 0)
Group= the service groups to enumerate
(default = ALL groups)
Syntax examples
sc query-enumerates the status of active services and drivers
sc query Messenger-shows the status of the Messenger service
sc Queryex Messenger-shows the extended status of the Messenger service
sc query type= Driver-Enumerate active drivers only
sc query type= Service-Enumerate Win32 services only
sc query state= All-enumerate all services and drivers
sc query bufsize= 50-enumeration buffer is 50 bytes
sc query ri= 14-Restore index = 14 when enumerated
sc queryex group= \ "\"-Enumeration of active services not in a group
sc query type= Service type= Interact-Enumerate all inactive services
sc query type= driver group= NDIS-Enumerate all NDIS drivers
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.