一、判断服务是否启动: rem Apache http server for /f "tokens=*" %%i in ('net start ^|find /i "Apache2"') do set srvApache2=%%i if "%srvApache2%"=="" (net start Apache2) 二、判断进程是否启动: for /f "tokens=*" %%i in ('tasklist ^|find /i "ApacheMonitor.exe"') do set prcApache2=%%i if "%prcApache2%"=="" (start Apache/bin/ApacheMonitor.exe)