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
Figure out how you'd do it at a command prompt and then issue that command with $ZF(-1)
But, "$ZF(-1)" is not return result of execution command.
You see in documentation:
"$ZF(-1) does not return operating system command results"
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KE…
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 }
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" w s,": ",$$$getServState(s),!Result:
USER>d ^test wudfsvc: Stopped WSearch: Running