将大量无用或者危险的服务关闭,参照许多服务优化的文章来看,大多需要禁用并停止20-30个服务将是一项比较烦琐的工作。 
						
						
						
						
						
							  对于经常重装系统的朋友来说,出于优化系统、减少内存占用亦或增强系统安全性能,往往都会修改很多系统服务的启动类型。将大量无用或者危险的服务关闭,参照许多服务优化的文章来看,大多需要禁用并停止20-30个服务将是一项比较烦琐的工作,我也是深受其害。然而从Windows XP开始,其自带的DOS工具中加入了一个sc.exe(Service Control)的文件,刚好可以对服务的启动类型以及服务的启动或者关闭等进行进行操作,再利用DOS的批处理优势,就可以把上面提到的种种操作进行大幅简化。    
  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