Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27360

[WMI QUESTION] in Win32_ProcessStartTrace how to get the process launched?

$
0
0
HERE IS MY CODE.
Code:

Namespace WMISample

    Public Class WMIReceiveEvent

        Public Overloads Shared Function Main() As Integer

            Try

                Dim query As New WqlEventQuery( _
                    "SELECT * FROM Win32_ProcessStartTrace")

                Dim watcher As New ManagementEventWatcher(query)
                Console.WriteLine("Waiting for an event...")

                Dim eventObj As ManagementBaseObject = watcher.WaitForNextEvent()

                Console.WriteLine("{0} event occurred.", eventObj("__CLASS"))

                ' Cancel the event subscription
                watcher.Stop()
                Return 0

            Catch err As ManagementException

                MessageBox.Show("An error occurred while trying to receive an event: " & err.Message)
            End Try
        End Function

    End Class
End Namespace


Viewing all articles
Browse latest Browse all 27360

Trending Articles