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.

  • + 1
  • 0
  • 137
  • 2
  • 2

Answers

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

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" s,": ",$$$getServState(s),!

Result:

USER>^test
wudfsvc: Stopped
WSearch: Running