命令格式
SC命令的格式:SC [Servername] command Servicename [Optionname= Optionvalues
*服务名是服务本身的名称而非显示名,
*=号后面要加一个空格,然后才能写选项名
SC命令共24个子命令,如下所示
sc boot sc config sc continue sc control sc create sc delete sc descrīption
sc enumdepend sc failure sc getdisplayname sc getkeyname sc interrogate
sc lock sc pause sc qc sc qdescrīption sc qfailure sc query sc queryex
sc querylock sc sdset sc sdshow sc start sc stop
比较常用的,禁止或开启服务
sc config tlntsvr start= auto '设置Telnet服务为自动
sc config tlntsvr start= disabled '设置telnet服务为禁止
启动或停止及暂停服务
sc start tlntsvr '启动Telnet服务
sc stop tlntsvr '停止Telnet服务
Sc pause tlntsvr '暂停Telnet服务
删除服务
Sc delete tlntsvr '删除Telnet服务,,但最好不要删除系统自带服务。。。
创建服务
sc create test binpath= c:\windows\notepad.exe start= auto ‘创建Notepad.exe为Test服务,启动方式为自动
SC help
------------------------------
DESCRIPTION:
SC is a command line program used for communicating with the
NT Service Controller and services.
USAGE:
sc <server> [command] [service name] <option1> <option2>...
The option <server> has the form ""
Further help on commands can be obtained by typing: "sc [command]"
Commands:
query-----------Queries the status for a service, or
enumerates the status for types of services.
queryex---------Queries the extended status for a service, or
enumerates the status for types of services.
start-----------Starts a service.
pause-----------Sends a PAUSE control request to a service.
interrogate-----Sends an INTERROGATE control request to a service.
continue--------Sends a CONTINUE control request to a service.
stop------------Sends a STOP request to a service.
config----------Changes the configuration of a service (persistant).
description-----Changes the description of a service.
failure---------Changes the actions taken by a service upon failure.
sidtype---------Changes the service SID type of a service.
qc--------------Queries the configuration information for a service.
qdescription----Queries the description for a service.
qfailure--------Queries the actions taken by a service upon failure.
qsidtype--------Queries the service SID type of a service.
delete----------Deletes a service (from the registry).
create----------Creates a service. (adds it to the registry).
control---------Sends a control to a service.
sdshow----------Displays a service's security descriptor.
sdset-----------Sets a service's security descriptor.
showsid---------Displays the service SID string corresponding to an ar
bitrary name.
GetDisplayName--Gets the DisplayName for a service.
GetKeyName------Gets the ServiceKeyName for a service.
EnumDepend------Enumerates Service Dependencies.
The following commands don't require a service name:
sc <server> <command> <option>
boot------------(ok | bad) Indicates whether the last boot should
be saved as the last-known-good boot configuration
Lock------------Locks the Service Database
QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
sc start MyService
Would you like to see help for the QUERY and QUERYEX commands? [ y | n ]:
转载于:https://blog.51cto.com/hujizhou/1039990