前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SC命令(windows服务开启/禁用)

SC命令(windows服务开启/禁用)

作者头像
全栈程序员站长
发布2022-07-05 14:47:08
2.5K0
发布2022-07-05 14:47:08
举报
文章被收录于专栏:全栈程序员必看

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文件,与保存好的批处理文件放在一起,然后运行批处理文件就可以。  

  对注冊表比較熟悉的朋友可能会想到用注冊表来设置服务的启动类型,这也是一种可行的方法,本身却有着内在不足。原因是服务启动类型在注冊表中相应的键值较长且分散,进行整理不方便直观且易错漏,所以这样的方法比較适用于无人值守的安装时使用。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/109174.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021年9月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
命令行工具
腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档