How can you tell if a program needs elevated rights?

Imagine the following scenario:

I have an exe file "DoINeedAdmin.exe" somewhere and want to check if this program will require administrator rights to run it.

It would be nice to try and run it and define it with some kind of failure return value.

Since Windows can obviously do this by adding an admin icon to the exe if it needs elevated privileges, I hope it is possible programmatically as well.

+3


source to share


3 answers


In short, there is no right way.

Windows will run the elevated program if it is listed in its manifest. They will also run it if the program name contains Install, Install, Update, Patch (possibly more) (unless disabled by local policy or manifest file ).



In addition, the application can also request elevation from code. There is no way to detect this in an external program.

+3


source


There is an undocumented function in shell32 (ordinal 865) that takes an LPCWSTR path and returns a nonzero BOOL if the path needs to be promoted. I don't know if this function validates external manifests.



+3


source


In short: Application Manifest . It is an XML file embedded in the executable and in particular the tag exists <requestedExecutionLevel level="requireAdministrator" />

.

+2


source







All Articles