CSharpFeeds - All your C# feeds in one place.

Sponsors

Friday, September 08, 2006

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

by BCLTeam via BCL Team Blog on 9/8/2006 6:55:00 PM

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 http://support.microsoft.com/?kbid=153183.

email it!bookmark it!digg it!

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

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us