last day (25 days later) » 

7:17 AM
0
Q: Access is denied : Performance Counters not working after installing Windows Service

Rahul NikateI'm having windows service. I'm using PerformanceCounter class to get CPU Data from Domain Machine. I'm running my code with Domain Admin privilege. So problem is here, I'm able to get CPU Data using PerformanceCounter while running code in Visual Studio. However, Same code is not working after ...

 
@Amit Sorry It didn't help. I've already seen this answer
 
It sounds like whatever user you choose to run the service as needs permission on the target machine to read the counters.
 
@mikez User running windows service is having Domain Admin permission. But same service works fine when I run through Visual Studio. Its not working after installing service.
 
Services typically run as Network Service or Local System are you saying you've manually changed the service logon after installation? What happens if you try to read the local machine's counters?
 
@mikez I didn't changed service logon manually. I'm able to read local machine's counters.
 
7:17 AM
If you didn't change it, then its probably still network service or local system. To change it right click the service in scm, go to the logon tab, and enter the username and password.
 
Ok mikez. Let me give a try
 
don't have much time for an extended chat, but let me know if that worked for you
 
sure mike
 
7:37 AM
So is the service's logon user supposed to be the same as your user, the one who is running VS?
The only other thing that I can think of is to check that the service logon user is in fact a member of Performance Log Users group on the target machine. Since the user is a domain admin, typically your domain policy would ensure this because the domain admin would also be a local admin.
Otherwise, I'm out of ideas.
Anyways, good luck, I have to go now.
 
8:09 AM
Thanks mikez
still working on it. ill let u know
 
 
2 hours later…
10:04 AM
@mikez Hi @mikez are you there. Your suggestion worked for me. I just added my user as Service Logon User
 

  last day (25 days later) »