• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Determine status of operating system services

Hi. Wonder if anyone could point me in the direction of some (preferably VB6) code that would allow me to build a utility to check the status of a particular service running under Win 2000 Server or Win 2003 Server?

The specific service in question probably won't mean that much to most - Zylab Fax service if you're interested - however hopefully the solution will be a generic one that would allow me to check the status of other services as well, or at least tell me if the status is indeterminate.

Any help would be appreciated. Thanks.

Regards,

YaHozna.
0
YaHozna
Asked:
YaHozna
  • 2
  • 2
1 Solution
 
mdiglioCommented:
Hello,
Try this out

'Begin Copy
'On Error Resume Next

Dim strService As String
strService = "Zylab Fax"

'If you want to run this on a remote machine replace the
'strComputer = "." with "RemoteCompName"
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select name, state from Win32_Service" _
& " where Name = '" & strService & "'", , 48)
For Each objItem In colItems
 
    MsgBox objItem.Name & " is in the " & objItem.State & " state."

Next
'End copy
0
 
YaHoznaAuthor Commented:
Hi and thanks. Looks like it might do the trick. I'll try it later today.

Regards,

YaHozna
0
 
YaHoznaAuthor Commented:
That worked perfectly. Many thanks.

Regards,

YaHozna.
0
 
mdiglioCommented:
Glad it worked for you!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now