[Reserved] using the command to install and uninstall windows service

Installation Services:
InstallUtil.exe service name
uninstall the service:
InstallUtil.exe service name / u or service name -uninstall

Start the service: net start service name
to stop the service: net stop service name
------------------------------------ -------------------------------------------------- --------------------

SC.exe retrieve and set control information about services. SC.exe can use to test and debug service programs. You can set service attributes stored in the registry to control how to start and run a service application as a daemon at startup. SC.exe parameters can configure a specific service, retrieve the current state of the service, or you can stop and start services. You can generate a batch file to call different SC.exe command to automatically activate or deactivate the service sequence. SC.exe provides functionality similar to the "Control Panel" "Administrative Tools" item in the "service."

Open CMD, run the SC command help get the following information:

Description:
SC is used for communication with the Service Control Manager command line program.
Usage:
SC [<server>] [Command] [-Service name] <the Option1> <option2> ...
Options <server> format is " \\ ServerName ", it indicates that the unit is omitted
can type "sc [command]" to further help get command
command:
query ----------- Queries state services, or enumeration type of state service.
queryex --------- extended status inquiry services, or enumeration type of state service.
start ----------- start the service.
pause ----------- PAUSE control request sent to the service.
interrogate ----- INTERROGATE transmission request to the service control.
continue -------- CONTINUE control request sent to the service.
Send STOP to stop ------------ request service.
config ---------- (permanently) to change the configuration of the service.
description ----- Change the description of the service.
operation performed when service failure --------- change failed.
qc -------------- configuration information inquiry services.
Description qdescription ---- inquiry services.
qfailure -------- query operation failed service performed.
delete ---------- Delete service (from the registry).
create ---------- create a service (add it to the registry).
control --------- sends control services.
sdshow ---------- display security descriptor services.
The security descriptor sdset ----------- set up the service.
GetDisplayName-- get DisplayName services.
GetKeyName ------ obtain ServiceKeyName services.
EnumDepend ------ dependencies enumerate services.

Example:
1) to start the service sc start MyService

2)创建服务 sc create BITS binpath= "C:\WINDOWS\system32\svchost.exe -k netsvcs" type= share start= auto displayname= "Background Intelligent Transfer Service" depend= RpcSs/EventSystem

3) Modify the service description
sc description BITS "use of idle network bandwidth to transfer files in the background."

4) Delete service
sc delete active defense

Remind you: behind sc cretate command with parameters such as [binPath =] equal sign must have a space, not a space you how frustrating not work, ha ha. Microsoft really funny ah, engage in such a function to confuse the people. Similarly, other parameters such as the back of the group =, after the equal sign displayname = spaces are required, otherwise sc create command does not successfully create a service, you will return to help.

The following command does not query service name:
sc <Server> <the Command> <the Option>
the Boot ------------ (the ok | Bad) Indicates whether the last boot is saved as a good start last known configuration
lock ------------ service database is locked
QueryLock ------- database query LockStatus SCManager

The following at the command of the SC query in explain:
list active service and driver status, use the command: sc query
displays messenger service, use the command: sc query messenger
just to name a driver activities, use the command: sc query type = driver
list Win32 service, use the command: sc query type = service
lists all the services and drivers, use the command: sc query state = all
with a 50 byte buffer to enumerate, use the command: sc query bufsize = 50
used in the recovery list index = 14, use the command: sc query ri = 14
list all interactive services, use the command: sc query type = service type = interact

myocode.blog.51cto.com/703470/521153

Reproduced in: https: //www.cnblogs.com/ericsun/archive/2013/02/05/2892473.html

Guess you like

Origin blog.csdn.net/weixin_33828101/article/details/93154953