How to get the Process Name with minimal privilege?

G

Guest

Hi,

System.Diagnostics.Process.GetCurrentProcess().ProcessName fails for a
caller with minimal privilege on Windows 2003 Server:
System.InvalidOperationException - Couldn't get process information from
remote machine.
System.ComponentModel.Win32Exception - Access is denied.

It works ok on Windows 2000 Professional.

A web search concerning this issue suggests that this is considered to be a
bug in 2003 Server in some quarters. The only work-around that I've come
across so far is to grant the caller access to the performance counters.
This is unacceptable.

Can anyone suggest another way for a caller with minimal privilege to
discover the name of the Win32 process within which it is executing? I don't
mind if it involves Interop, just as long as it works with minimal privilege.

Thanks
David Razzetti
 
P

Peter Huang [MSFT]

Hi David,

The System.Diagnostics.Process Class uses performance data to obtain
information on processes on the system.
So the user needs to be added to the "Performance Monitor Users" Group to
call run the Process.GetCurrentProcess.ProcessName.
If you do not want to add the user into the group and you just want to get
the process name.
You may try to use
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase and
parse the process name which is the exe file name.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top