用指令: SC Delete 服務名
如果服務名稱中帶空格,則請在服務名稱前面用半角的雙引号括起
如 SC delete "Adobe LM Service"
在cmd下可有兩種方法打開,net和sc,net用于打開沒有被禁用的服務,文法是:
net start 服務名
net stop 服務名
用sc可打開被禁用的服務,文法是:
sc config 服務名 start= demand //手動
sc condig 服務名 start= auto //自動
sc config 服務名 start= disabled //禁用
sc start 服務名
注:1)服務名不一定是你在服務面闆看到的那個名,例如,你要打開被禁用的telnet服務,sc config telnet start= auto,報錯:[SC] OpenService FAILED 1060,因為telnet的服務名不是telnet而是tlntsvr, sc config tlntsvr start= auto 就OK了,在服務面闆裡檢視telnet屬性,從可執行檔案的路徑裡可看到服務程式名,即指令中的服務名。 2)start=後面有空格,少了就有錯
sc.exe指令功能清單: 注:以下指令中。=号後面都有一個空格,=号前面沒有空格!
1.更改服務的啟動狀态(這是比較有用的一個功能)
2.删除服務(除非對自己電腦的軟、硬體所需的服務比較清楚,否則不建議删除任何系統服務,特别是基礎服務)
3.停止或啟動服務(功能上類似于net stop/start,但速度更快且能停止的服務更多)
具體的指令格式如下:
修改服務啟動類型的指令行格式為(特别注意start=後面有一個空格)
sc config 服務名稱 start= demand(設定服務為手動啟動)
sc config 服務名稱 start= disabled(設定服務為禁用)
停止/啟動服務的指令行格式為
sc stop/start 服務名稱
注意:平時常接觸的都是服務的顯示名稱,而以上所指是服務名稱,都可以在控制台->管理工具->服務裡面,輕按兩下對應的服務來查詢。
先舉例說明一下具體的設定方法:
如設定遠端系統資料庫服務為手動其格式為
sc config RemoteRegistry start= demand
設為禁用的格式為:
sc config RemoteRegistry start= disabled
停止服務則格式為:
sc stop RemoteRegistry
首先把自己所需設定的服務名稱查到之後,按照上面的格式做成批處理檔案,重裝系統之後隻要運作批處理檔案即可。
以下是我的設定,以XpSp2為藍本,可比對所用的系統進行增删和修改。注:未加入XpSp2的自動更新、安全中心、防火牆。
sc config Alerter start= demand
sc config TrkWks start= demand
sc config helpsvc start= demand
sc config policyAgent start= demand
sc config dmserver start= demand
sc config WmdmpmSn start= demand
sc config Spooler start= demand
sc config NtmsSvc start= demand
sc config seclogon start= demand
sc config Schedule start= demand
sc config WebClient start= demand
sc config W32Time start= demand
sc config WZCSVC start= demand
sc config ERSvc start= demand
sc config Themes start= demand
sc config FastUserSwitchingCompatibility start= disabled
sc config Messenger start= disabled
sc config protectedStorage start= disabled
sc config SSDpSRV start= disabled
sc config TermService start= disabled
sc config ShellHWDetection start= disabled
如果需要立即關閉服務也可把以下代碼跟在上面的代碼之後
sc stop W32Time
sc stop ShellHWDetection
sc stop TrkWks
sc stop helpsvc
sc stop dmserver
sc stop policyAgent
sc stop Spooler
sc stop seclogon
sc stop Schedule
sc stop WZCSVC
sc stop ERSvc
sc stop Themes
sc stop FastUserSwitchingCompatibility
sc stop protectedStorage
sc stop SSDpSRV
sc stop WebClient
最後把修改好之後的代碼存為services.cmd,在以後進行服務設定時,直接運作事先儲存好的批處理檔案就可以做到事半功倍了。
看到這裡,使用Win2000的朋友也不必失望,sc.exe這個指令行工具對Win2000同樣适用,可從裝有WinXp或者Win2003的機器裡面拷貝sc.exe檔案,與儲存好的批處理檔案放在一起,然後執行批處理檔案即可。
對系統資料庫比較熟悉的朋友可能會想到用系統資料庫來設定服務的啟動類型,這也是一種可行的方法,本身卻有着内在不足。原因是服務啟動類型在系統資料庫中對應的鍵值較長且分散,進行整理不友善直覺且易錯漏,是以這種方法比較适用于無人值守的安裝時使用