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:\Windows\System32\cmd.exe

2.輸入:sc.exe create MongoDB binPath= "\"c:mongo\bin\mongod.exe\" --service --config=\"c:mongo\mongod.cfg\"" DisplayName= "MongoDB" start= "auto" (這幾個引號很重要)

3.出現:[SC] CreateService 成功

4.輸入:net start MongoDB

5.出現:MongoDB 服務正在啟動 .

    MongoDB 服務已經啟動成功。

 

--------

 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM