Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Function to highlight stopped services

Posted on 2006-06-19
5
Medium Priority
?
160 Views
Last Modified: 2010-04-30
Hi
I would like to write a utility which will check the status of the services on a server and identify any services which are marked as automatic but have stopped due to some reason or other.

Any pointers to get me going on this one?

Thanks
0
Comment
Question by:john_123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 2000 total points
ID: 16933827


Private Sub Command1_Click()
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service", , 48)
For Each objItem In colItems
    If objItem.StartMode = "Auto" And objItem.State = "Stopped" Then
        Debug.Print "AcceptPause: " & objItem.AcceptPause
        Debug.Print "AcceptStop: " & objItem.AcceptStop
        Debug.Print "Caption: " & objItem.Caption
        Debug.Print "CheckPoint: " & objItem.CheckPoint
        Debug.Print "CreationClassName: " & objItem.CreationClassName
        Debug.Print "Description: " & objItem.Description
        Debug.Print "DesktopInteract: " & objItem.DesktopInteract
        Debug.Print "DisplayName: " & objItem.DisplayName
        Debug.Print "ErrorControl: " & objItem.ErrorControl
        Debug.Print "ExitCode: " & objItem.ExitCode
        Debug.Print "InstallDate: " & objItem.InstallDate
        Debug.Print "Name: " & objItem.Name
        Debug.Print "PathName: " & objItem.PathName
        Debug.Print "ProcessId: " & objItem.ProcessId
        Debug.Print "ServiceSpecificExitCode: " & objItem.ServiceSpecificExitCode
        Debug.Print "ServiceType: " & objItem.ServiceType
        Debug.Print "Started: " & objItem.Started
        Debug.Print "StartMode: " & objItem.StartMode
        Debug.Print "StartName: " & objItem.StartName
        Debug.Print "State: " & objItem.State
        Debug.Print "Status: " & objItem.Status
        Debug.Print "SystemCreationClassName: " & objItem.SystemCreationClassName
        Debug.Print "SystemName: " & objItem.SystemName
        Debug.Print "TagId: " & objItem.TagId
        Debug.Print "WaitHint: " & objItem.WaitHint
    End If
Next


End Sub

0
 
LVL 1

Author Comment

by:john_123
ID: 16934089
Hi, am I supposed to be using the name of the computer in the strComputer variable?
This is Visual Basic Express 2005 and not working properly.
I am used to VB5 and VB6 not really Express - would this function be different in this environment?
0
 
LVL 1

Author Comment

by:john_123
ID: 16934101
I am also writing and testing this code on XP Pro rather than Server 2003 - would this cause problems?
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16934452
this is vb6 code
0
 
LVL 1

Author Comment

by:john_123
ID: 16975040
I havejust found out that VB Express 2005 has built in components for performance monitoring and service control.
Many thanks anyhow. John.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question