I am attempting to check thatthe service ACR BRIDGE
is running and start it is not.
cd C:\Users\ET012364\Desktop\PSEXEC
psservice \\ccapps query "ACR BRIDGE"
pause
I understand that I could achieve this using a combination of error levels and the stop start commands. However, I am more interested in knowing how to manipulate the data returned by this command.
SERVICE_NAME: ACRBridge
DISPLAY_NAME: ACR Bridge
ACR Bridge for controlling both Master and Standby Collect Corp Recorders. If t
he service is down, it will restart after one minute.
GROUP : someorder
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0 ms
This is what is returned and what I want to extract the STATE
value from.
This is the code I ended up using. I think it's the most simple of the solutions.
@echo off
cd C:\Users\ET012364\Desktop\PSEXEC
psservice \\ccapps query "ACR BRIDGE" | find "RUNNING"
if "%ERRORLEVEL%"=="0" (
echo ACR BRIDGE is running
) else (
echo ACR BRIDGE on CCAPPS is not running
pause
)
psservice \\ccapps query "DIALERMESSAGEMONITOR"| find "RUNNING"
if "%ERRORLEVEL%"=="0" (
echo Dialer MessageMonitor is running
) else (
echo Dialer MessageMonitor on CCAPPS is not running
pause
)