I have the following code that is being run from under a local user that belongs to Users
group:
String processName = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;
that fails with System.ComponentModel.Win32Exception
claiming that Access is denied
with the following stack:
System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
System.Diagnostics.Process.get_MainModule()
Now MSDN article has "community content" at the bottom of the page saying that this behavior is observed when code is being called by an elevated process or from under another user because it will try to open the process.
Okay, it tries to open that process, but the code is running under a user belonging to Users
group, why is it denied access to open the process?