日期:2014-05-17 浏览次数:20824 次
@echo off >"%temp%\MyService.txt" type nul >>"%temp%\MyService.txt" sc query mysql for /f "tokens=1-4 delims= " %%a in ('findstr "STATE" %temp%\MyService.txt') do ( if "%%d" neq "RUNNING" ( sc start mysql>nul ) ) del /q "%temp%\MyService.txt"
------解决方案--------------------
试试我这个,呵呵
@echo off ::判断服务是否被禁用,如果被禁用就设置为自动 wmic service where "name="mysql" and startmode="disabled"" call changestartmode ::判断服务是否启动,如果未启动就启动此服务 wmic service where "name="mysql" and state="stopped"" call startservice