Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if a program needs elevated rights? [duplicate]

Imagine the following scenario:

I have an exe-file "DoINeedAdmin.exe" somewhere and want to check if this program would require admin-rights to start it.

It would be okay trying to start it and determine it by some failure return value.

Since Windows can obviously do this by adding the admin-icon to the exe if it needs elevated rights, I hope it's possible programmatically too.

like image 344
Art1st Avatar asked Sep 10 '25 17:09

Art1st


1 Answers

There is a undocumented function in shell32 (ordinal 865) that takes a LPCWSTR path and returns a non-zero BOOL if the path requires elevation. I don't know if this function checks external manifests though.

like image 60
Anders Avatar answered Sep 13 '25 09:09

Anders