Question Tiago Ribeiro · Jul 16, 2018

Status of an operating system service

Hey Guys.

Is possible i know in COS the state of the one service the operation system?
One example:

What's state of service WinDefend for example, in operating system Windows.
I would like to know the status of the service.

Comments

Rod Dorman · Jul 16, 2018

Figure out how you'd do it at a command prompt and then issue that command with $ZF(-1)

0
Rod Dorman  Jul 16, 2018 to Tiago Ribeiro

If the command you're using doesn't support redirection to a file use a command pipe e.g. SET $ZT="CommandErr" OPEN Command:"QR" FOR { USE Command READ Text USE $P ; do something with the text } CommandErr ; SET ZE=$ZE SET $ZT="" USE $P CLOSE Command IF $P(ZE,">")="<ENDOFFILE" { ; successful completion } ELSE { ; something happened }

0
Vitaliy Serdtsev · Jul 17, 2018

test.mac:

#include %systemInclude

  #define getServState(%serviceName) ##class(%Activate.GenericObject).GetObject("winmgmts:\\.\root\cimv2").InvokeMethod1("Get",$$$FormatText("Win32_Service.Name=%1",$$$quote(%serviceName))).GetProperty("State")

  f s="wudfsvc","WSearch" s,": ",$$$getServState(s),!

Result:

USER>^test
wudfsvc: Stopped
WSearch: Running
0