保存当前系统服务启动状态的脚本

Batch

@echo off
rem  get current date and time
for /f "tokens=1,2,3 delims=-/. " %%j in ('Date /T') do set FILENAME=srv_%%j%%k%%l
for /f "tokens=1,2 delims=: " %%j in ('TIME /T') do set FILENAME=%FILENAME%-%%j%%k_%RANDOM%.ba_

rem get all service name
sc query type= service state= all|findstr /r /C:"SERVICE_NAME:" >tmpsrv.txt
echo Save Service Start State In %FILENAME%

rem save service start state into batch file
rem

echo @echo off >"%FILENAME%"
echo echo Restore The Service Start State Saved At %TIME% %DATE% form %USERDOMAIN% >>"%FILENAME%"
echo pause >>"%FILENAME%"

for /f "tokens=2 delims=:" %%j in (tmpsrv.txt) do (
sc qc %%j|findstr START_TYPE >tmpstype.txt
for /f "tokens=4 delims=:_ " %%s in (tmpstype.txt) do echo sc config %%j start= %%s >>"%FILENAME%"
)
echo exit >>"%FILENAME%"

del tmpsrv.txt
del tmpstype.txt
exit

Windows XP SP3 Pro Chs

@echo off
pause
sc config  Alerter start= DISABLED 
sc config  ALG start= DEMAND 
sc config  AppMgmt start= DEMAND 
sc config  AudioSrv start= AUTO 
sc config  BITS start= DEMAND 
sc config  Browser start= AUTO 
sc config  CiSvc start= DEMAND 
sc config  ClipSrv start= DISABLED 
sc config  COMSysApp start= DEMAND 
sc config  CryptSvc start= AUTO 
sc config  DcomLaunch start= AUTO 
sc config  Dhcp start= AUTO 
sc config  dmadmin start= DEMAND 
sc config  dmserver start= AUTO 
sc config  Dnscache start= AUTO 
sc config  Dot3svc start= DEMAND 
sc config  EapHost start= DEMAND 
sc config  ERSvc start= AUTO 
sc config  Eventlog start= AUTO 
sc config  EventSystem start= DEMAND 
sc config  FastUserSwitchingCompatibility start= DEMAND 
sc config  helpsvc start= AUTO 
sc config  HidServ start= AUTO 
sc config  hkmsvc start= DEMAND 
sc config  HTTPFilter start= DEMAND 
sc config  ImapiService start= DEMAND 
sc config  LanmanServer start= AUTO 
sc config  lanmanworkstation start= AUTO 
sc config  LmHosts start= AUTO 
sc config  Messenger start= DISABLED 
sc config  mnmsrvc start= DEMAND 
sc config  MSDTC start= DEMAND 
sc config  MSIServer start= DEMAND 
sc config  napagent start= DEMAND 
sc config  NetDDE start= DISABLED 
sc config  NetDDEdsdm start= DISABLED 
sc config  Netlogon start= DEMAND 
sc config  Netman start= DEMAND 
sc config  Nla start= DEMAND 
sc config  NtLmSsp start= DEMAND 
sc config  NtmsSvc start= DEMAND 
sc config  PlugPlay start= AUTO 
sc config  PolicyAgent start= AUTO 
sc config  ProtectedStorage start= AUTO 
sc config  RasAuto start= DEMAND 
sc config  RasMan start= DEMAND 
sc config  RDSessMgr start= DEMAND 
sc config  RemoteAccess start= DISABLED 
sc config  RemoteRegistry start= AUTO 
sc config  RpcLocator start= DEMAND 
sc config  RpcSs start= AUTO 
sc config  RSVP start= DEMAND 
sc config  SamSs start= AUTO 
sc config  SCardSvr start= DEMAND 
sc config  Schedule start= AUTO 
sc config  seclogon start= AUTO 
sc config  SENS start= AUTO 
sc config  SharedAccess start= AUTO 
sc config  ShellHWDetection start= AUTO 
sc config  Spooler start= AUTO 
sc config  srservice start= AUTO 
sc config  SSDPSRV start= DEMAND 
sc config  stisvc start= DEMAND 
sc config  SwPrv start= DEMAND 
sc config  SysmonLog start= DEMAND 
sc config  TapiSrv start= DEMAND 
sc config  TermService start= DEMAND 
sc config  Themes start= AUTO 
sc config  TlntSvr start= DISABLED 
sc config  TrkWks start= AUTO 
sc config  UMWdf start= AUTO 
sc config  upnphost start= DEMAND 
sc config  UPS start= DEMAND 
sc config  VSS start= DEMAND 
sc config  W32Time start= AUTO 
sc config  WebClient start= AUTO 
sc config  winmgmt start= AUTO 
sc config  WmdmPmSN start= DEMAND 
sc config  Wmi start= DEMAND 
sc config  WmiApSrv start= DEMAND 
sc config  wscsvc start= AUTO 
sc config  wuauserv start= AUTO 
sc config  WZCSVC start= AUTO 
sc config  xmlprov start= DEMAND 
exit
Windows Server 2003

Windows 7

转载于:https://www.cnblogs.com/Tty725/archive/2010/12/28/1919105.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值