Windows手动添加服务 sc create


命令行创建服务项: sc create

用法:
sc create [service name] [binPath= ] ...

选项:
注意: 选项名称包括等号,等号和值之间需要一个空格
type=     (默认 = own)
start=               (默认 = demand)
error=                                            (默认 = normal)
binPath= <.exe 文件的 BinaryPathName>
group=
tag=
depend= <依存关系(以 / (斜杠)分隔)>
obj=              (默认= LocalSystem)
DisplayName= <显示名称>
password= <密码>

示例:将 Redis 添加到服务,以管理员身份运行命令提示符

sc create Redis6.2.6 binPath= "D:\Redis6.2.6\redis-server.exe --service-run \"D:\Redis6.2.6\redis-windows.conf\"" DisplayName= Redis6.2.6 start= auto

命令中的双引号使用反斜杠加引号 \" 来进行转义处理

设置服务的描述: sc description

用法:
sc description [service name] [description]

示例:修改 Redis 描述

sc description Redis6.2.6 "This service runs the Redis server"