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:

<FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">%systemInclude

  </FONT><FONT COLOR="#0000ff">#define </FONT><FONT COLOR="#000000">getServState(%serviceName) </FONT><FONT COLOR="#0000ff">##class(%Activate.GenericObject).GetObject(</FONT><FONT COLOR="#008000">"winmgmts:\.\root\cimv2"</FONT><FONT COLOR="#0000ff">).InvokeMethod1(</FONT><FONT COLOR="#008000">"Get"</FONT><FONT COLOR="#0000ff">,$$$FormatText</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Win32_Service.Name=%1"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$$$quote</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">%serviceName</FONT><FONT COLOR="#000000">))</FONT><FONT COLOR="#0000ff">).GetProperty(</FONT><FONT COLOR="#008000">"State"</FONT><FONT COLOR="#0000ff">)

  f </FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"wudfsvc"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"WSearch" </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">": "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$$$getServState</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">),!</FONT>

Result:
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">^test</FONT>
wudfsvc: Stopped
WSearch: Running
0