I have written a small console app that lists performance data. The application in itself works fine however when I use it on my terminal server I only get the processes for the user I am logged in with which in this case is the administrator. I need to be able to see this data for all users. See code below is there a way to do this using the Win32 query or do I need to start over using something else? The data must include the CPU usage and ProcID. I have tried other ideas such as the get process functions which allow me to get processes for all users but they do not allow me to get the CPU percentage directly like the Win32 Performance data does.
Imports System.Management
Imports System
Module Module1
Sub Main()
Using searcher As New ManagementObjectSearcher(( _
"SELECT * FROM Win32_PerfFormattedData_PerfProc_Process"))
Using results As ManagementObjectCollection = searcher.Get
For Each result As ManagementObject In results
Dim processId As UInteger = DirectCast(result.GetPropertyValue("IDProcess"), UInteger)
Dim processName As String = DirectCast(result.GetPropertyValue("Name"), String)
Dim cpu As ULong = DirectCast(result.GetPropertyValue("PercentProcessorTime"), ULong)
result.Dispose()
If processName = "iexplore" Then
Console.WriteLine("{0} - {1} - {2}", processId, processName, cpu)
End If
Next
End Using
End Using
End Sub
End Module

New Topic/Question
Reply




MultiQuote


|