I think it's simpler to use the Unix-like command GREP (also from the Resource Kit) to check shell output results. This will avoid creating and reading temporary files ....

I use a script like this one:

$SERVICE_NAME="W3SVC"
SHELL "%COMSPEC% /C SC.EXE QUERY " + $SERVICE_NAME + " |GREP RUNNING"
IF @ERROR=0
? "It's running"
ELSE
? "It's NOT running"
ENDIF