highestAvailable
will elevate if the current user is an administrator. Which is consistent with what you have observed. When a standard user runs the process, no UAC dialog is shown and the process runs with the standard token. When an admin user executes, the UAC consent dialog is shown and the process will then run elevated.
If your program requires admin rights to function then you need to use requireAdministrator
. When a standard user starts such a process, the over-the-shoulder UAC dialog is shown. That gives the user an opportunity to ask an admin to supply their credentials.
You should only use highestAvailable
if your program is capable of running with a limited functionality in case the user is not able to elevate. This is what is meant by mixed-mode in the MSDN topic linked by your question.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…