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

原文連接地址:https://blog.csdn.net/cd520yy/article/details/30976131安全

sc.exe命令功能列表:  工具

  1.更改服務的啓動狀態(這是比較有用的一個功能)   .net

  2.刪除服務(除非對本身電腦的軟、硬件所需的服務比較清楚,不然不建議刪除任何系統服務,特別是基礎服務)  命令行

  3.中止或啓動服務(功能上相似於net stop/start,但速度更快且能中止的服務更多)server

  具體的命令格式以下:  blog

  修改服務啓動類型的命令行格式爲(特別注意start=後面有一個空格)  cmd

  sc config 服務名稱 start= demand(設置服務爲手動啓動)   it

  sc config 服務名稱 start= disabled(設置服務爲禁用)   io

  中止/啓動服務的命令行格式爲   ast

  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文件,與保存好的批處理文件放在一塊兒,而後執行批處理文件便可。  

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

相關文章
相關標籤/搜索