恖椡専嶕偼偰側
邮薏贁艂饡\帵偟偰偄傑偡C斉偼偙偪傜
i-mobile

合菽迋處缻s寢壥傪敾抐偡傞曽朄偵偮偄偰嫵偊偰偔偩偝偄

-----------------------------------------------------
# sc query [话宿綎糫

SERVICE_NAME: [话宿綎糫
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
-----------------------------------------------------

幚峴寢壥偺STATE 偑1񎎙4偺偳傟側偺偐偵傛偭偰張棟傪暘偗偨偄偺偱偡
傕偟1?3側傜 曄悢result 偵G黏4側傜K饝銚鼈穫閭鎮蓚祩膜echo偱夋柺偵昞帵偡傞
忦審暘婒偺晹暘偺傒偱傕傛偄偺偱偛夞摎傪偍婅偄偟傑偡


仠幙栤幰: Ryo0524
仠睹恨:狠诉 唱剔惂嶌
✍钒馨霓:ECHO ng SC State 合菽
仜 忬懺 :廔椆
劋 夞摎悢 : 3/3審

仱嵟怴偺夞摎傊

1 仠 Mook
仠26芜草 娃侥陛话

偄傠偄傠側傗傝曽偑偁傞偲巚偄傑偡偑な薤羵葌鐗簨L偺傛偆側曽朄偱偳偆偱偟傚偆偐

@Echo Off

Call :DoesRunningService "Schedule"
Call :DoesRunningService "WPCSvc"
Call :DoesRunningService "abcd"

Pause
Exit /B

REM --------------------------------------
REM 话宿絺虖髴詡饖m擣傪偡傞惶拶傲
REM --------------------------------------
:DoesRunningService
 SC Query %1 | FindStr -C:"4 RUNNING">NUL
 If ERRORLEVEL 1 ( Echo %1 NG ) Else (Echo %1 OK )
Exit /B

幚峴寢壥偵 "4 RUNNING" 偑偁傞偐偳偆偐傪敾掕婎弨偵偟偰偄傑偡

http://www.ne.jp/asahi/hishidama/home/tech/windows/bat.html#ERRO...


2 仠 utagawh
仠27芜草

for /f "usebackq tokens=1,2,3*" %i in (`sc query state"=" all`) do (if /i "%i" == "state" (if "%k" == "4" (echo ok) else (echo ng )))

sc query 偺寢壥傪for偱張棟偟偰偼偳偆偱偟傚偆偐丠

``撪傪sc query 话宿綎 偲偟偰挷傋偨偄话宿綍猣or暥傪暲傋偨傎偆偑偄偄偲巚偄傑偡

偁偲at抬操拞偵彂偔応崌偼%i偼%%i偲偡傞昁梫偑偁傝傑偡


3 仠 hissssa
仠27芜草

兽抬操偱合菽迋虖o椡寢壥偐傜張棟傪暘偗傞偵偼OR侔踢傪巊偭偨敾掕偺巇妡偗傪嶌傞昁梫偑偁傝傑偡

扨弮側椺偲偟偰偼偙傫側姶偠偱偟傚偆偐

@echo off

setlocal enabledelayedexpansion

FOR /F "delims=" %%L IN ('sc query w32time') do (

SET CL=%%L

SET CL2=!CL: =!

IF "!CL2:~0,7!"=="STATE:1" SET result=NG

IF "!CL2:~0,7!"=="STATE:2" SET result=NG

IF "!CL2:~0,7!"=="STATE:3" SET result=NG

IF "!CL2:~0,7!"=="STATE:4" SET result=OK

)

echo result:%result%

偙偺椺偼合菽迋虖o椡寢壥傪慡峴専嵏偟偰傑偡偺偱鴹蜅莻瓊葌艂贰傑偨暥帤楍偺愭摢偐傜7暥帤傑偱傪寛傔懪偪偱愗傝庢偭偰敾掕偟偰傑偡偐傜眰虠醾虖陯噦蛻鍙鋾v偱傕敾掕偡傞暥帤楍偵傛偭偰偼岆摦嶌偟傑偡偺偱偛拲堄偔偩偝偄

娭楢幙栤


仠幙栤傪傕偭偲扵偡仠



0.恖椡専嶕偼偰側寞踢
8.偙偺瓦凹迋饤F払偵徯夘
9.偙偺瓦凹迋虗鎿獋
懳墳婡庬堦棗
偍栤偄崌傢偣
唾踢/偍抦傜偣
鄹薏
柍椏瞻晦皳o榐
偼偰側寞踢