title: Monitoring the execution of all process
body: <p>How I can do it?</p>
  
  <p>I don't want to use a timer + an array of processes (because that's the newbie way that I allways did) I'm looking for something better and improved.</p>
  
  <p>I've tried using ManagementEventWatcher but this code example is not working in Windows 7 (I don't get any error, but is not showing the MsgBoxes):</p>
  
  <pre><code>Public Class Form1
  
  Dim WithEvents startWatch As New System.Management.ManagementEventWatcher(New System.Management.WqlEventQuery("SELECT * FROM Win32_ProcessStartTrace"))
  Dim WithEvents stopWatch As New System.Management.ManagementEventWatcher(New System.Management.WqlEventQuery("SELECT * FROM Win32_ProcessStopTrace"))
  
  Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
      AddHandler startWatch.EventArrived, AddressOf startWatch_EventArrived
      AddHandler stopWatch.EventArrived, AddressOf stopWatch_EventArrived
      startWatch.Start()
      stopWatch.Start()
  End Sub
  
  Public Sub startWatch_EventArrived(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs)
      MsgBox("Process started: " &amp; e.NewEvent.Properties("ProcessName").Value)
  End Sub
  
  Private Sub stopWatch_EventArrived(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs)
      MsgBox("Process stopped: " &amp; e.NewEvent.Properties("ProcessName").Value)
  End Sub
  
  Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
      startWatch.Stop()
      stopWatch.Stop()
  End Sub
  
  End Class
  </code></pre>