XP服务管理脚本

@echo off
echo “make by bkd”
:begin
cls

echo 1,备份自动启动服务;2,还原自动启动服务;3,备份非自动启动服务;4,将所有服务设置为手动启动;5,打开服务管理器;q,退出

set /p go=choose 1,2,3,4,5,q
if %go%==1 goto getAutoStartServices
if %go%==2 goto restoreAutoStartServices
if %go%==3 goto getInactiveServices
if %go%==4 goto setServicesStartOndemand
if %go%==5 goto openServicesManager
if %go%==q goto exit
goto begin

:getAutoStartServices
echo >autoStartServices.txt
for /f “tokens=2 delims=: ” %%i in (‘sc query^|find “E_N”‘) do (echo %%i >>autoStartServices.txt)
type autoStartServices.txt
goto begin

:restoreAutoStartServices
for /f %%i in (‘type autoStartservices.txt’) do (sc config %%i start= auto)
goto begin

:getInactiveServices
echo >InactiveServices.txt
sc query state= inactive|find “E_N” >tmp.txt
for /f “tokens=2 delims=: ” %%i in (‘type tmp.txt’) do echo %%i >>InactiveServices.txt
del /Q /s tmp.txt
type InactiveServices.txt
goto begin

:setServicesStartOndemand
sc query state= all|find “E_N” >tmp.txt
echo >tmp1.txt    
for /f “delims=: tokens=2” %%i in (‘type tmp.txt’) do (echo %%i>>tmp1.txt&sc config %%i start= demand)

:openServicesManager
services.msc

:exit

Author: bkdwei