我正在尝试检查该服务ACR BRIDGE
是否正在运行并启动它不是。
cd C:\Users\ET012364\Desktop\PSEXEC
psservice \\ccapps query "ACR BRIDGE"
pause
我知道我可以使用错误级别和停止启动命令的组合来实现这一点。但是,我更感兴趣的是了解如何操作此命令返回的数据。
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
这是返回的内容,也是我想要从中提取STATE
值的内容。
这是我最终使用的代码。我认为这是最简单的解决方案。
@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
)