cmd sc.exe 添加一个服务 以MongoDB为例

-----

描述:
在注册表和服务数据库中创建服务项。
用法:
sc <server> create [service name] [binPath= ] <option1> <option2>...

选项:
注意: 选项名称包括等号。
等号和值之间需要一个空格。
type= <own|share|interact|kernel|filesys|rec|userown|usershare>
(默认 = own)
start= <boot|system|auto|demand|disabled|delayed-auto>
(默认 = demand)
error= <normal|severe|critical|ignore>
(默认 = normal)
binPath= <.exe 文件的 BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <依存关系(以 / (斜杠)分隔)>
obj= <AccountName|ObjectName>
(默认= LocalSystem)
DisplayName= <显示名称>
password= <密码>

---------

步骤:

1.以管理员方式运行:C:WindowsSystem32cmd.exe

2.输入:sc.exe create MongoDB binPath= ""c:mongoinmongod.exe" --service --config="c:mongomongod.cfg"" DisplayName= "MongoDB" start= "auto" (这几个引号很重要)

3.出现:[SC] CreateService 成功

4.输入:net start MongoDB

5.出现:MongoDB 服务正在启动 .

    MongoDB 服务已经启动成功。

--------

ctrl+r 然后输入 service.msc 就能看到添加的服务了

原文地址:https://www.cnblogs.com/norie/p/8783263.html