copyright 1999 - 2014 by heinz prelle - hannover  - lenbachstraße 42 - | impressum
Beispiel: VB .Net - WMI - Liste inaktiver Dienste anzeigen
Option Explicit On
Option Strict Off

Imports System.Management

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles Button1.Click
        MakeListListFromInactiveServices(My.Computer.Name) '".")
    End Sub

    Private Sub MakeListListFromInactiveServices(ByVal Computername As String)
            If Computername <> "" Then
                Dim query As String = _
                    "winmgmts:" & "{impersonationLevel=impersonate}!\\" & Computername & "\root\cimv2"

                Dim service As Object = GetObject(query)
                Dim wmiInstances As Object = _
                    service.ExecQuery("Select * from Win32_Service where State <> 'Running'")

                For Each Instance As Object In wmiInstances
                MessageBox.Show("Necessary input is missing.", "Info")
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString(), "Info")
        End Try
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles MyBase.Load
        With Me
            .Text = "Liste inaktiver Dienste ermitteln"
            .Button1.Text = "Test"
        End With
    End Sub
End Class
Sourcecode Visual Basic