How can I detect if a specific process is elevated or not. This process is different than the process where my code is running. I'd like to be able to do this from with PowerShell or C#.
How to detect if a specific process is elevated using dotnet or powershell
740 views Asked by klumsy At
2
There are 2 answers
0
On
Please try out this answer: https://stackoverflow.com/a/4497572/717732
That UacHelper
will need some minor changes. Like, IsProcessElevated
uses OpenProcessToken
on CurrentProcess - you will need to change the IsProcessElevated
fo a function and make the Process
a parameter, so you can inspect any, not just current one.
In general, this class does all that you'd need to. It inspects the security properties assigned to the process. I think that code speaks by itself.
BTW. If you think that code is OK for your needs, please mark your question as 'duplicate' of that one - it will help others in finding that code.
Maybe this can help
From http://www.powershellmagazine.com/2013/03/29/pstip-detecting-if-a-certain-process-is-elevated/