命令行大全

sc

小猪老师 发表于 2020-06-24 18:23浏览次数:

SC是用于与服务和服务控制管理器进行通信的命令行程序。

查看英文版

目录:

1 sc 运行系统环境

2 sc 语法

3 sc 示例

sc 运行系统环境

Windows vista

Windows 7

Windows 8

Windows 10

sc 语法

sc[command] [service name]...

选项的格式为“ \\ ServerName”

指令

queryex 查询服务的扩展状态,或枚举服务类型的状态。
start 启动服务。 用法: sc <服务器>start[服务名称]...
pause 将暂停控制请求发送到服务。 用法: sc <服务器>pause[服务名称]
interrogate 将INTERROGATE控制请求发送到服务。 用法: sc <服务器>interrogate[服务名称]
continue 将CONTINUE控制请求发送到服务。 用法: sc <服务器>continue[服务名称]
stop 向服务发送一个STOP请求。

用法:

sc <服务器>STOP[服务名称]>
=服务停止的可选原因代码号,由以下元素组成,格式为:

标志:主要原因:次要原因

[例如1:2:8表示硬件:磁盘(计划外)]

标记
------------------
1-计划外
2-自定义
4-计划中

主要原因
------------------
1-其他
2-硬件
3-操作系统
4-软件
5-应用程序
64-255-自定义

次要原因
------------------
1-其他
2-维护
3-安装
4-升级
5-重新配置
6-挂起
7-不稳定
8-磁盘
9-网卡
10-环境
11-硬件驱动程序
12-其他驱动程序
13-Service Pack
14-软件更新
15-安全修复
16-安全
17-网络连接
18-WMI
19-Service Pack卸载
20-软件更新卸载
22-安全修复程序卸载
23-MMC
256 -65535-Custom

< comment >=出于上述原因的可选注释(最多127个字符)
config 更改服务的配置(永久)。
用法:
sc <服务器>config[服务名称] <选项1> <选项2> ..
type= < own|share|interact|kernel|filesys|rec|adapt|userown|usershare >
start= < boot|system|auto|demand|disabled|delayed-auto >
error= < normal|severe|critical|ignore >
binPath= < BinaryPathName to the .exe file >
group= < LoadOrderGroup >
tag= < yes|no >
depend= < Dependencies(separated by / (forward slash)) >
obj= < AccountName|ObjectName >
DisplayName= < display name >
password= < password >
description

更改服务的描述。

用法:

sc <服务器>description[服务名称] [description]

failure

更改服务在失败时采取的措施。

用法:

sc <服务器>failure[服务名称] <选项1> <选项2> ... 选项:

reset=

<无故障的时间长度(以秒为单位),之后将故障计数重置为0(可能是INFINITE)>

(必须与action =结合使用)

reboot= < 失败后重新启动之前广播的消息 >
command= <失败时要运行的命令行>
actions=

<失败操作及其延迟时间(以毫秒为单位),以/(正斜杠)分隔-例如,run / 5000 / reboot / 800 有效操作为>

(必须与reset结合使用=选项)

failureflag

更改服务的失败操作标志设置。如果此设置为0(默认值),则仅当服务进程在服务处于SERVICE_STOPPED以外的状态下终止时,

SCM(服务控制管理器)才会对服务启用已配置的失败操作。

如果此设置为1,则除了上述服务进程终止之外,如果服务进入带有非0的Win32退出代码的SERVICE_STOPPED状态,

则SCM会对服务启用已配置的失败操作。

如果服务未配置任何失败操作,则将忽略此设置。

用法:

sc <服务器> failureflag [服务名称] [flag]

sidtype

更改服务的SID(服务安全标识符)类型设置。 如果此设置为“ unrestricted”,则由于该进程中的第一个服务正在启动,

因此当下一次启动该服务进程时,SCM将将该服务的SID添加到该服务进程令牌中。此设置仅对Win32用户模式服务有效。

如果此设置为“ restricted”,则由于该进程中的第一个服务正在启动,因此下次启动该服务进程时,SCM将将该服务的SID添加到该服务进程令牌中。

同样,此服务的SID将添加到流程令牌中的限制SID列表中。流程令牌将是受限令牌。有关受限制令牌的详细信息,请参见MSDN。

此设置仅对Win32用户模式服务有效。同样,对于共享流程服务,在流程中共同托管的所有服务都必须设置此SID类型才能生效。

如果此设置为“ none”,则SCM不会将服务的SID添加到服务进程令牌中。

用法:

sc <服务器> sidtype [服务名称] [类型] 选项:

type < none|unrestricted|restricted >
privs

更改服务的所需特权设置。由于服务进程中的第一个服务正在启动,因此特权设置在服务进程启动时生效。

那时,SCM(服务控制管理器)计算将在同一流程中托管的所有服务所需的所有特权的并集,然后使用这些特权创建流程。

缺少此设置将意味着该服务需要安全子系统允许该服务在配置的帐户中运行的进程的所有特权。

用法:

sc <服务器>privs[服务名称] [privileges] 选项

privileges < privileges(separated by="" (forward="" slash))="" >
[ E.g., SeBackupPrivilege/SeRestorePrivilege]
managedaccount

更改运行服务的帐户是否使用托管密码。 如果此设置为“ true”,则SCM将在启动服务时向NetLogon请求帐户密码。

如果此设置为“ false”,则SCM将使用配置的帐户密码。

用法:

sc <服务器>managedaccount [服务名称] [type]

type < true|false >
qc

查询服务的配置信息。

用法:

sc <服务器> qc [服务名称]

qdescription

查询服务描述。

用法:

sc <服务器> qdescription [服务名称]

qfailure

查询服务在失败时采取的措施。

用法:

sc <服务器> qfailure [服务名称]

qfailureflag

检索服务的失败操作标志设置。如果此设置为0(默认值),则仅当服务进程在服务处于SERVICE_STOPPED以外的状态下终止时,

SCM(服务控制管理器)才会对服务启用已配置的失败操作。如果此设置为1,则除了上述服务进程终止之外,

如果服务进入带有非0的Win32退出代码的SERVICE_STOPPED状态,则SCM会对服务启用已配置的失败操作。

如果服务未配置任何失败操作,则将忽略此设置。

用法:

sc <服务器> qfailureflag [服务名称]

qsidtype

查询服务的SID(服务安全标识符)类型设置。 如果此设置为“ unrestricted”,则由于下一次启动服务中的第一个服务,

SCM(服务控制管理器)将在下次启动服务过程时将该服务的SID添加到服务过程令牌中。

此设置仅对Win32用户模式服务有效。 如果此设置为“ restricted”,则由于该进程中的第一个服务正在启动,因此下次启动该服务进程时,

SCM将将该服务的SID添加到该服务进程令牌中。同样,此服务的SID将添加到流程令牌中的限制SID列表中。

流程令牌将是受限令牌。有关受限制令牌的详细信息,请参见MSDN。此设置仅对Win32用户模式服务有效。

同样,对于共享流程服务,在流程中共同托管的所有服务都必须设置此SID类型才能生效。

如果此设置为“ none”,则SCM不会将服务的SID添加到服务进程令牌中。

用法:

sc <服务器> qsidtype [服务名称]

qprivs

查询服务所需的特权设置。由于服务进程中的第一个服务正在启动,因此特权设置在服务进程启动时生效。

那时,SCM计算将在同一进程中托管的所有服务所需的所有特权的并集,然后使用这些特权创建进程。

如果没有此设置,则表示该服务需要安全子系统允许在该服务的已配置帐户中运行的进程的所有特权。

用法:

sc <服务器> qprivs [服务名称]

qtriggerinfo

查询服务的触发参数。

用法:

sc <服务器> qtriggerinfo [服务名称]

qpreferrednode

查询Win32服务的首选NUMA节点。此设置仅对其自己的过程服务有效。如果服务没有首选节点设置,则查询将失败。

用法:

sc <服务器> qpreferrednode [服务名称]

qmanagedaccount

查询服务是否使用具有LSA管理的密码的帐户。

用法:

sc <服务器> qmanagedaccount [服务名称]

qprotection

查询服务是否标记为在受保护的进程中启动。请注意,此设置无法更改。

用法:

sc <服务器> qprotection [服务名称]

quserservice

Q从指定的用户服务模板创建的同一会话中,当前用户的用户服务实例查询。

用法:

sc quserservice <服务模板名称>

delete

从注册表中删除服务条目。如果该服务正在运行,或者另一个进程对该服务具有打开的句柄,则该服务将标记为删除。

用法:

sc <服务器>delete[服务名称]

create

在注册表和服务数据库中创建服务条目。

用法:

sc <服务器>create[服务名称] [binPath =] <选项1> <选项2> ... 选项:

type= < own | share | interact | kernel | filesys | rec | userown | usershare > (默认=拥有)
start= < boot | system | auto | demand | disabled | delayed-auto > (默认=需求)
error= < normal|severe|critical|ignore >
(default = normal)< /normal|severe|critical|ignore >
binPath= < BinaryPathName to the .exe file >
group= < LoadOrderGroup >
tag= < yes|no >
depend= < Dependencies(separated by / (forward slash)) >
obj= < AccountName|ObjectName >
(default = LocalSystem)
DisplayName= < display name >
password= < password >
control

将控件发送到服务。

用法:

sc <服务器>控件[服务名称] <值> <值> =用户定义的控制代码

<值> = < 参数更改| netbindadd | netbindremove | netbindenable | netbinddisable >

sdshow

显示服务的安全描述符。

用法:

sc <服务器> sdshow <服务名称> < showrights >

sdset

设置服务的安全描述符。

用途:

sc <服务器> sdset <服务名称>

showsid

显示与任意名称相对应的服务SID字符串。

该名称可以是现有或不存在的服务的名称。

用法:

sc showsid [名称]

triggerinfo

配置服务的触发参数。

用法:

sc <服务器> triggerinfo [服务名称] <选项1> <选项2> ...

选项:

start/device/UUID/HwId1/... <在具有一个或多个硬件ID字符串或兼容ID字符串的指定设备接口类UUID 字符串到达时启动服务>
start/custom/UUID/data0/..

<在到达指定的自定义ETW提供程序UUID字符串的事件时启动服务,

该字符串带有一个或多个十六进制字符串格式的二进制数据项,例如ABCDABCD以设置4字节数据>

stop/custom/UUID/data0/...

<当事件从指定的自定义ETW提供程序UUID字符串到达时停止服务,

该事件带有一个或多个十六进制字符串格式的二进制数据项(例如ABCDABCD)以设置4字节数据>

start/strcustom/UUID/data0/.. <从具有一个或多个可选字符串数据项的指定自定义ETW提供程序UUID字符串到达事件时启动服务>
stop/strcustom/UUID/data0/.. <在事件到达指定的自定义ETW提供者UUID字符串以及一个或多个可选字符串数据项后停止服务>
start/lvlcustom/UUID/data0/..

<当事件到达指定的自定义ETW提供者UUID字符串时,启动服务,

该字符串的级别高于或等于十六进制数字格式的数据项,例如0x01>

stop/lvlcustom/UUID/data0/..

<当事件到达指定的自定义ETW提供者UUID字符串时,停止服务,

该字符串的级别高于或等于十六进制数字格式的数据项,例如0x01>

start/kwanycustom/UUID/data0/..

<在到达指定的自定义ETW提供程序UUID字符串的事件后,

使用与十六进制数字格式(例如0x0A03)的数据项中的任何位匹配的关键字来启动服务>

stop/kwanycustom/UUID/data0/..

<使用指定的关键字与十六进制数字格式(例如0x0A03)匹配数据项中任何位的关键字,

停止从指定的自定义ETW提供程序UUID字符串到达事件的服务>

start/kwallcustom/UUID/data0/..

<在到达指定的自定义ETW提供者UUID字符串的事件后,

使用与十六进制数字格式(如0x0A03)匹配数据项中所有位的关键字启动服务>

stop/kwallcustom/UUID/data0/..

<使用来自指定自定义ETW提供程序UUID字符串的事件停止服务,

该关键字使用与十六进制数字格式(如0x0A03)匹配数据项中所有位的关键字>

start/networkon <在第一个IP地址上启动服务>
stop/networkoff
<在零IP地址上停止服务>
start/domainjoin <启动域加入服务>
stop/domainleave <在域休假时停止服务>
start/portopen/parameter <在打开网络端口时启动服务。该参数以分号分隔,形式为portnumber; protocolname; imagepath;服务名称>
stop/portclose/parameter <在关闭网络端口后停止服务。该参数以分号分隔,形式为portnumber; protocolname; imagepath;服务名称>
start/machinepolicy <当计算机组策略更改或启动时存在时启动服务>
start/userpolicy <当用户组策略更改或启动时存在时启动服务>
start/rpcinterface/UUID <当请求到达给定接口的RPC端点映射器时启动服务>
start/namedpipe/pipename <当到达指定命名管道的请求时启动服务。不要在管道名称中包含"\\.\pipe\"部分
delete <删除现有的触发参数>
preferrednode

更改Win32服务的首选NUMA节点。此设置仅对其自己的过程服务有效。要删除现有设置,请将节点号设置为-1。

如果提供了无效的首选节点号,则更改请求将失败。

用法:

sc <服务器> preferrednode [服务名称] [节点号]

GetDisplayName

获取服务的DisplayName。

用法:

sc <服务器> GetDisplayName <服务密钥名称> <缓冲区大小>

GetKeyName

使用显示名称作为输入,获取与特定服务关联的密钥名称。

用法:

scGetKeyName <服务显示名称>

EnumDepend

枚举服务依赖项。

用法:

sc <服务器> EnumDepend <服务名称> <缓冲区大小>

以下命令不需要服务名称:
sc< server > < command > < option >

boot (ok | bad) 指示是否应将上次引导保存为最近一次的良好引导配置
Lock 锁定服务数据库
QueryLock 查询SCManager数据库的LockStatus

QUERY和QUERYEX选项

如果在查询命令后跟服务名称,则返回该服务的状态。在这种情况下,其他选项不适用。如果query命令后面没有任何内容或下面列出的选项之一,则将枚举服务。

type= 要枚举的服务类型 (driver, service, userservice, all)
(默认值= service)
state= 要枚举的服务状态 (inactive, all)
(默认值 = active)
bufsize=

枚举缓冲区的大小(以字节为单位)

(默认= 4096)

ri=

开始枚举的恢复索引号

(默认= 0)

group=

要枚举的服务组

(默认=all groups)

sc[command] [service name]...

The optionhas the form "\\ServerName"

Commands

queryex Queries the extended status for a service, or enumerates the status for types of services.
start Starts a service. Usage: scstart [service name]...
pause Sends a PAUSE control request to a service. Usage: scpause [service name]
interrogate Sends an INTERROGATE control request to a service. Usage: scinterrogate [service name]
continue Sends a CONTINUE control request to a service. Usage: sccontinue [service name]
stop Sends a STOP request to a service. Usage: scstop [service name]
= Optional reason code number for service stop formed with the following elements in the format: Flag:Major reason:Minor reason [E.g., 1:2:8 means Hardware: Disk (Unplanned)] Flag
------------------
1 - Unplanned
2 - Custom
4 - Planned Major reason
------------------
1 - Other
2 - Hardware
3 - Operating System
4 - Software
5 - Application
64-255 - Custom Minor reason
------------------
1 - Other
2 - Maintenance
3 - Installation
4 - Upgrade
5 - Reconfiguration
6 - Hung
7 - Unstable
8 - Disk
9 - Network Card
10 - Environment
11 - Hardware Driver
12 - Other Driver
13 - Service Pack
14 - Software Update
15 - Security Fix
16 - Security
17 - Network Connectivity
18 - WMI
19 - Service Pack Uninstall
20 - Software Update Uninstall
22 - Security Fix Uninstall
23 - MMC
256-65535 - Custom= Optional comment for the reason above (127 character maximum)
config Changes the configuration of a service (persistent). Usage: scconfig [service name]... Options:
type= < own|share|interact|kernel|filesys|rec|adapt|userown|usershare>
start= < boot|system|auto|demand|disabled|delayed-auto>
error= < normal|severe|critical|ignore>
binPath= < binarypathname to="" the="" .exe="" file="" >
group= < LoadOrderGroup >
tag= < yes|no>
depend= < dependencies(separated by="" (forward="" slash))="">
obj= < accountname|objectname>
DisplayName= < display name >
password= < password >
description Changes the description of a service. Usage: scdescription [service name] [description]
failure Changes the actions taken by a service upon failure. Usage: scfailure [service name]... Options:
reset= (Must be used in conjunction with actions= )
reboot= < Message broadcast before rebooting on failure >
command= < Command line to be run on failure >
actions= < Failure actions and their delay time (in milliseconds), separated by / (forward slash) -- e.g., run/5000/reboot/800 Valid actions are (Must be used in conjunction with the reset= option)
failureflag Changes the failure actions flag setting of a service. If this setting is 0 (default), the SCM (Service Control Manager) enables configured failure actions on the service only if the service process terminates with the service in a state other than SERVICE_STOPPED. If this setting is 1, the SCM enables configured failure actions on the service if the service enters the SERVICE_STOPPED state with a Win32 exit code other than 0 in addition to the service process termination as above. This setting is ignored if the service does not have any failure actions configured. Usage: scfailureflag [service name] [flag]
sidtype Changes the SID (service security identifier) type setting of a service. If this setting is "unrestricted," the SCM will add this service's SID to the service process token when the service process starts the next time due to the first service in the process being started. This setting is valid only for Win32 user mode services. If this setting is "restricted," the SCM will add this service's SID to the service process token when the service process starts the next time due to the first service in the process being started. Also, this service's SID is added to the restricting SID list in the process token. The process token will be a restricted token. See MSDN for details on a restricted token. This setting is valid only for Win32 user mode services. Also, for a share process service, all services cohosted in the process must have this SID type set for this to take effect. If this setting is "none," the SCM will not add the service's SID to the service process token. Usage: scsidtype [service name] [type] Options:
type
privs Changes the required privileges setting of a service. The privilege settings take effect when the service process starts due to the first service in the process being started. At that time, the SCM (Service Control Manager) computes the union of all privileges required by all services that will be hosted in the same process and then creates the process with those privileges. An absence of this setting is taken to imply that the service requires all the privileges that the security subsystem allows for the process running in the service's configured account. Usage: scprivs [service name] [privileges] Options:
privileges
[E.g., SeBackupPrivilege/SeRestorePrivilege]
managedaccount Changes whether the account in which the service runs uses a managed password. If this setting is "true", the SCM will request the account password from NetLogon when starting the service. If this setting is "false", the SCM will use the configured account password. Usage: scmanagedaccount [service name] [type] Options:
type
qc Queries the configuration information for a service. Usage: scqc [service name]
qdescription Queries the description for a service. Usage: scqdescription [service name]
qfailure Queries the actions taken by a service upon failure. Usage: scqfailure [service name]
qfailureflag Retrieves the failure actions flag setting of a service. If this setting is 0 (default), the SCM (Service Control Manager) enables configured failure actions on the service only if the service process terminates with the service in a state other than SERVICE_STOPPED. If this setting is 1, the SCM enables configured failure actions on the service if the service enters the SERVICE_STOPPED state with a Win32 exit code other than 0 in addition to the service process termination as above. This setting is ignored if the service does not have any failure actions configured. Usage: scqfailureflag [service name]
qsidtype Queries the SID (service security identifier) type setting of a service. If this setting is "unrestricted," the SCM (Service Control Manager) will add this service's SID to the service process token when the service process starts the next time due to the first service in the process being started. This setting is valid only for Win32 user mode services. If this setting is "restricted," the SCM will add this service's SID to the service process token when the service process starts the next time due to the first service in the process being started. Also, this service's SID is added to the restricting SID list in the process token. The process token will be a restricted token. See MSDN for details on a restricted token. This setting is valid only for Win32 user mode services. Also, for a share process service, all services cohosted in the process must have this SID type set for this to take effect. If this setting is "none," the SCM will not add the service's SID to the service process token. Usage: scqsidtype [service name]
qprivs Queries the required privileges setting for a service. The privilege settings take effect when the service process starts due to the first service in the process being started. At that time, the SCM computes the union of all privileges required by all services that will be hosted in the same process and then creates the process with those privileges. An absence of this setting is taken to imply that the service requires all the privileges that the security subsystem allows for a process running in the service's configured account. Usage: scqprivs [service name]
qtriggerinfo Queries the trigger parameters of a service. Usage: scqtriggerinfo [service name]
qpreferrednode Queries the preferred NUMA node for a Win32 service. This setting is valid only for its own process services. If the service has no preferred node setting, then the query will fail. Usage: scqpreferrednode [service name]
qmanagedaccount Queries whether a service uses an account with a password managed by LSA. Usage: scqmanagedaccount [service name]
qprotection Queries whether the service is marked to start in a protected process. Note that this setting cannot be changed. Usage: scqprotection [service name]
quserservice Queries for a user service instance for the current user in the same session created from the user service template specified. Usage: sc quserservice
delete Deletes a service entry from the Registry. If the service is running, or another process has an open handle to the service, the service is marked for deletion. Usage: scdelete [service name]
create Creates a service entry in the Registry and Service Database. Usage: sccreate [service name] [binPath= ]... Options:
type= < own|share|interact|kernel|filesys|rec|userown|usershare>
(default = own)
start= < boot|system|auto|demand|disabled|delayed-auto>
(default = demand)
error= < normal|severe|critical|ignore>
(default = normal)
binPath= < binarypathname to="" the="" .exe="" file="" >
group= < LoadOrderGroup >
tag= < yes|no>
depend= < dependencies(separated by="" (forward="" slash))="" >< /dependencies(separated >
obj= < accountname|objectname >
(default = LocalSystem)
DisplayName= < display name >
password= < password >
control Sends a control to a service. Usage: sccontrol [service name]
= user-defined control code
= See also sc stop, sc pause, etc.
sdshow Displays a service's security descriptor. Usage: scsdshow
sdset Sets a service's security descriptor. Usge: scsdset
showsid Displays the service SID string corresponding to an arbitrary name. The name can be that of an existing or non-existent service. Usage: sc showsid [name]
triggerinfo Configures the trigger parameters of a service. Usage: sctriggerinfo [service name]... Options:
start/device/UUID/HwId1/... < Start the service on arrival of the specified device interface class UUID string with one or more hardware ID strings or compatible ID strings >
start/custom/UUID/data0/.. < Start the service on arrival of an event from the specified custom ETW provider UUID string with one or more binary data items in hexadecimal string format such as ABCDABCD to set 4-byte data >
stop/custom/UUID/data0/... < Stop the service on arrival of an event from the specified custom ETW provider UUID string with one or more binary data items in hexadecimal string format such as ABCDABCD to set 4-byte data >
start/strcustom/UUID/data0/.. < Start the service on arrival of an event from the specified custom ETW provider UUID string with one or more optional string data items >
stop/strcustom/UUID/data0/.. < Stop the service on arrival of an event from the specified custom ETW provider UUID string with one or more optional string data items >
start/lvlcustom/UUID/data0/.. < Start the service on arrival of an event from the specified custom ETW provider UUID string with a level higher or equal to the data items in hexadecimal number format such as 0x01 >
stop/lvlcustom/UUID/data0/.. < Stop the service on arrival of an event from the specified custom ETW provider UUID string with a level higher or equal to the data items in hexadecimal number format such as 0x01 >
start/kwanycustom/UUID/data0/.. < Start the service on arrival of an event from the specified custom ETW provider UUID string with a keyword that matches any of the bits in the data items in hexadecimal number format such as 0x0A03 >
stop/kwanycustom/UUID/data0/.. < Stop the service on arrival of an event from the specified custom ETW provider UUID string with a keyword that matches any of the bits in the data items in hexadecimal number format such as 0x0A03 >
start/kwallcustom/UUID/data0/.. < Start the service on arrival of an event from the specified custom ETW provider UUID string with a keyword that matches all of the bits in the data items in hexadecimal number format such as 0x0A03 >
stop/kwallcustom/UUID/data0/.. < Stop the service on arrival of an event from the specified custom ETW provider UUID string with a keyword that matches all of the bits in the data items in hexadecimal number format such as 0x0A03 >
start/networkon < Start the service on first IP address >
stop/networkoff < Stop the service on zero IP addresses >
start/domainjoin < Start the service on domain join >
stop/domainleave < Stop the service on domain leave >
start/portopen/parameter < start the="" service="" on="" opening="" of="" a="" network="" port.="" parameter="" is="" semi-colon="" delimited="" form="" portnumber;protocolname;imagepath;="" servicename="">
stop/portclose/parameter < stop the="" service="" on="" closing="" of="" a="" network="" port.="" parameter="" is="" semi-colon="" delimited="" form="" portnumber;protocolname;imagepath;="" servicename="">
start/machinepolicy < Start the service when machine group policy changes or is present at boot >
start/userpolicy < Start the service when user group policy changes or is present at boot >
start/rpcinterface/UUID < Start the service when a request arrives at the RPC Endpoint Mapper for the given interface >
start/namedpipe/pipename < start the="" service="" when="" a="" request="" arrives="" for="" specified="" named="" pipe.="" do="" not="" include="" "\\.\pipe\"="" portion="" of="" pipe's="" name="" >
delete < Delete the existing trigger parameters >
preferrednode Changes the preferred NUMA node for a Win32 service. This setting is valid only for its own process services. To delete an existing setting, set the node number as -1. If an invalid preferred node number is supplied, then the change request will fail. Usage: scpreferrednode [service name] [node number]
GetDisplayName Gets the DisplayName for a service. Usage: scGetDisplayName
GetKeyName Gets the key name associated with a particular service, using the display name as input. Usage: scGetKeyName
EnumDepend Enumerates Service Dependencies. Usage: scEnumDepend

1

The following commands don't require a service name:
sc

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

QUERY and QUERYEX OPTIONS

If the query command is followed by a service name, the status for that service is returned. Further options do not apply in this case. If the query command is followed by nothing or one of the options listed below, the services are enumerated.

type= Type of services to enumerate (driver, service, userservice, all)
(default = service)
state= State of services to enumerate (inactive, all)
(default = active)
bufsize= The size (in bytes) of the enumeration buffer
(default = 4096)
ri= The resume index number at which to begin the enumeration
(default = 0)
group= Service group to enumerate
(default = all groups)

查看英文版

查看中文版

sc 示例

st start hope

如果“hope”服务存在,则此代码将启动它。

sc query

枚举活动服务和驱动程序的状态。

sc query eventlog

显示事件日志服务的状态。

st start hope

If the "hope" service existed, this code would start it.

sc query

Enumerates the status for active services & drivers.

sc query eventlog

Displays the status for the eventlog service.

查看英文版

查看中文版