How to Read Performance Counters Without Administrator Privileges [Ryan Byington]

If you have ever tried to read performance counter data on a Windows 2003 machine as a non admin user you will have likely seen an exception like the following:

System.UnauthorizedAccessException: Access to the registry key 'Global' is denied.
   at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity)
   at Microsoft.Win32.RegistryKey.GetValue(String name)
   at System.Diagnostics.PerformanceMonitor.GetData(String item)
   at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item)

Windows 2003, Windows XP x64 Edition, and Vista require that the user be part of the Performance Monitor Users group to read performance counter data. Simply adding your non admin user to this group will fix this problem.

Accessing counters remotely is another story though. On Windows 2003, Windows XP x64 Edition, and Vista you still must be part of the Performance Monitor Users group on the remote machine but there is a problem with the PerformanceCounter class where it tries to read some registry keys on the remote machine that a non admin users do not have access to. To give your user read access to these keys without having to be an admin on the remote machine complete the following steps on the remote machine:

  1. Open the Registry Editor by going to the Start Menu and selecting Run…, then type “regedit”, and click the OK button.
  2. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurePipeServers\winreg registry key.
  3. Right click on the "winreg" key and select Permissions. Add users or groups to which you want to grant Read access.
  4. Exit Registry Editor and restart Windows.

For more explanation on this process see https://support.microsoft.com/?kbid=153183.