Usage: /services
Result of use:
Opens window @services if not already open.
(If the window was previously opened, it clears the buffer)
Then the script proceeds to list all currently running services and what the status of those services is.
alias services {
var %a,%b,%c,%d,%e
%a = a $+ $ticks
%b = b $+ $ticks
%c = c $+ $ticks
%d = 1
.comopen %a wbemscripting.swbemlocator
if (!$comerr) {
.comclose %a $com(%a,connectserver,3,dispatch* %b)
if ($com(%b)) {
.comclose %b $com(%b,instancesof,3,bstr,win32_service,dispatch* %c)
if ($com(%c)) {
noop $com(%c,count,3)
%e = $com(%c).result
if (!$window(@services)) {
window -ek[0] @services
}
else {
clear @services
}
while (%d <= %e) {
aline @services Service Name -> $comval(%c,%d,displayname)
aline @services Status -> $comval(%c,%d,state)
inc %d
}
.comclose %c
}
}
}
else { echo -a * /services: component object model error. }
}