SC命令(windows服務開啟/禁用)

來源:互聯網
上載者:User

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檔案,與儲存好的批次檔放在一起,然後執行批次檔即可。  

  對註冊表比較熟悉的朋友可能會想到用註冊表來設定服務的啟動類型,這也是一種可行的方法,本身卻有著內在不足。原因是服務啟動類型在註冊表中對應的鍵值較長且分散,進行整理不方便直觀且易錯漏,所以這種方法比較適用於無人值守的安裝時使用。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.