首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

BAT 兑现服务自动开启关闭

2012-08-10 
BAT 实现服务自动开启关闭@echo offcolor 0B::判断服务是否被禁用,如果被禁用就设置为自动::wmic service

BAT 实现服务自动开启关闭
@echo off
color 0B
::判断服务是否被禁用,如果被禁用就设置为自动
::wmic service where "name="MSSQL$SQL2005" and startmode="disabled"" call changestartmode
::判断服务是否启动,如果未启动就启动此服务
::wmic service where "name="MSSQL$SQL2005" and state="stopped"" call startservice
net start >service.txt
find /i service.txt "SQL Server (SQL2005)"
if errorlevel 1 goto start
if errorlevel 0 goto stop
:start
net start MSSQL$SQL2005
goto success
:stop
net stop MSSQL$SQL2005
goto end
:success
::net start
@echo 服务开启成功,谢谢使用!
:end
del "service.txt"
@pause>nul
exitBAT 实现服务自动开启关闭

热点排行