Imports System.Management
Imports System.Drawing
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
showstatus()
Timer1.Interval = 10000 ' 10 Sec.
Timer1.Enabled = True
End Sub
Public Sub showstatus()
Labeltime.Text = DateTime.Now.ToString()
Dim i As Integer = 0
Dim exchser(14) As String
Dim class1 As ManagementClass = New ManagementClass("Win32_Service")
For Each ob As ManagementObject In class1.GetInstances
Dim item1 As String = ob.GetPropertyValue("Name").ToString
For i = 0 To 13
If item1 = exchser(i) Then
Select Case item1
Case "MSMQ"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service1.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service1.ForeColor = Color.Red
Else
Service1.ForeColor = Color.Orange
End If
Case "MSExchangeADTopology"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service2.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service2.ForeColor = Color.Red
Else
Service2.ForeColor = Color.Orange
End If
Case "MSExchangeFDS"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service3.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service3.ForeColor = Color.Red
Else
Service3.ForeColor = Color.Orange
End If
Case "MSExchangeIS"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service4.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service4.ForeColor = Color.Red
Else
Service4.ForeColor = Color.Orange
End If
Case "MSExchangeMailSubmission"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service5.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service5.ForeColor = Color.Red
Else
Service5.ForeColor = Color.Orange
End If
Case "MSExchangeMailboxAssistants"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service6.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service6.ForeColor = Color.Red
Else
Service6.ForeColor = Color.Orange
End If
Case "MSExchangeMonitoring"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service7.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service7.ForeColor = Color.Red
Else
Service7.ForeColor = Color.Orange
End If
Case "MSExchangePop3"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service8.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service8.ForeColor = Color.Red
Else
Service8.ForeColor = Color.Orange
End If
Case "MSExchangeRepl"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service9.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service9.ForeColor = Color.Red
Else
Service9.ForeColor = Color.Orange
End If
Case "MSExchangeSearch"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service10.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service10.ForeColor = Color.Red
Else
Service10.ForeColor = Color.Orange
End If
Case "MSExchangeSA"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service11.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service11.ForeColor = Color.Red
Else
Service11.ForeColor = Color.Orange
End If
Case "MSExchangeTransport"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service12.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service12.ForeColor = Color.Red
Else
Service12.ForeColor = Color.Orange
End If
Case "MSExchangeTransportLogSearch"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service13.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service13.ForeColor = Color.Red
Else
Service13.ForeColor = Color.Orange
End If
Case "msftesql-Exchange"
If ob.GetPropertyValue("State").ToString = "Running" Then
Service14.ForeColor = Color.Green
ElseIf ob.GetPropertyValue("State").ToString = "Stopped" Then
Service14.ForeColor = Color.Red
Else
Service14.ForeColor = Color.Orange
End If
Case Else
End Select
End If
Next
'------------------------
Next
End Sub
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
showstatus()
End Sub
End Class