S Topkaya
S Topkaya

Reputation: 51

Win32_PerfRawData_PerfProc_Process class not working, not others works

I'm trying to get CPU usage data with WMI. For this purpose I'm using the Win32_PerfRawData_PerfProc_Process class. When I run below code, I do not get any result.

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2","SELECT * FROM Win32_PerfRawData_PerfProc_Process");
var data = searcher.Get();

Until here there is no any error, if I try to use data object, app waiting until I close it.

I made some research, but found nothing useful.

NOTE: Other WMI class queries work fine. And I need to use WMI (not performance counters).

Upvotes: 1

Views: 1083

Answers (2)

BalintPogatsa
BalintPogatsa

Reputation: 129

I was following initially this msdn article and used dcomcnfg + wmimgmt.msc to directly add my user:

https://learn.microsoft.com/en-us/windows/win32/wmisdk/securing-a-remote-wmi-connection

The result was that I could read and get the results of many WMI queries, e.g.:

  • SELECT * FROM Win32_OperatingSystem
  • SELECT * FROM Win32_Process

But Win32_PerfRawData_PerfProc_Process was always giving an empty result remotely (locally it was returning the data).

The solution was to add my user to the Performance Monitor Users group in Computer Management / Local Users and Groups

Upvotes: 0

Shadow Con
Shadow Con

Reputation: 1

Please take a look at registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\PerfProc\Performance and here the value of "Disable Performance Counters". It should be set to "0" for this Class to work.

Upvotes: 0

Related Questions