標籤:
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 RemoteRegistry 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 RemoteRegistry ;遠程改動注冊表
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檔案,與儲存好的批次檔放在一起,然後運行批次檔就可以。
對注冊表比較熟悉的朋友可能會想到用注冊表來設定服務的啟動類型,這也是一種可行的方法,本身卻有著內在不足。原因是服務啟動類型在注冊表中相應的鍵值較長且分散,進行整理不方便直觀且易錯漏,所以這樣的方法比較適用於無人值守的安裝時使用。
SC命令(windows服務開啟/禁用)