Windows服務的管理主要使用兩個命令: sc net 其中:sc可以修改服務的屬性等資訊,可以添加刪除服務等:
#查看建立服務的資訊
C:/Documents and Settings/sina>sc create Creates a service entry in the registry and Service Database. SYNTAX: sc create [service name] [binPath= ] <option1> <option2>... CREATE OPTIONS: NOTE: The option name includes the equal sign. type= <own|share|interact|kernel|filesys|rec> (default = own) start= <boot|system|auto|demand|disabled> (default = demand) error= <normal|severe|critical|ignore> (default = normal) binPath= <BinaryPathName> group= <LoadOrderGroup> tag= <yes|no> depend= <Dependencies(separated by / (forward slash))> obj= <AccountName|ObjectName> (default = LocalSystem) DisplayName= <display name> password= <password>
C:/Documents and Settings/sina>
#刪除服務
sc delete servicename
#啟動服務
sc start servicename
#停止服務
sc stop servicename
#查詢所有服務的狀態
sc query
#查詢指定服務的狀態
sc query servicename
#查詢服務的描述資訊
sc qdescription servicename
#查詢服務的配置資訊
sc qc servicename
#根據服務名稱查顯示名稱
sc getdisplayname servicename
#根據顯示名稱查詢服務名稱
sc getkeyname displayname
#修改服務的描述
sc description servicename “描述資訊”
#修改服務的更多配置資訊
sc config servicename displayname= “顯示名" type= ......
|
注意:sc 操作的都是服務的服務名稱(不是顯示名稱),如telnet 的顯示名稱為telnet,服務名稱為Tlntsvr ,所以用
sc啟動telnet為:
sc start Tlntsvr
sc停止telnent為:
sc stop Tlntsvr
sc可以修改服務的顯示名稱,但是不能修改服務名稱,如果服務名稱比較複雜,寫起來就很麻煩,但是有修改不了,怎麼辦...
就用net命令吧,net可以操作服務名稱也可以操作服務的顯示名稱,如果服務的顯示名稱比較複雜,可以用sc修改的簡單一些,如:我的apache的服務名稱很長 為:APMServe-Apache ,在命令裡敲起來就比較麻煩,而且顯示名稱也這麼長,修改顯示名稱:
sc config APMServe-Apache DisplayName= httpd
|
注意: httpd 和等號之間的空格一定是要有的。
這時就可以有一下命令了:
net start httpd net stop httpd
當然:
net start APMServe-Apache
net stop APMServe-Apache
也是可以的
更多net的使用:
net /?
|