Some programs are automatically asking for administrator rights when you run them. These programs are marked with a little shield in the bottom right corner:
Now I'm wondering how I could accomplish this in C++.
Is there a function for this or do I need some special compiler/linker commands for that?
Press Windows+R to open the “Run” box. Type “cmd” into the box and then press Ctrl+Shift+Enter to run the command as an administrator.
To do so, search for Command Prompt in the Start menu, right-click the Command Prompt shortcut, and select Run as administrator. The Administrator user account is now enabled, although it has no password.
Actually, this shield which means the application will need to run from administrator is set from the operating system if the application going to use any feature of that machine which needs permission from administrator.
You do not need to set anything from your app for that.
Hope the answer may help you.
You must be probably looking for CreateProcessAsUser or CreateProcessWithLogonW function.
There is one more option like this:-
Soemthing like this:
And as Syam correctly mentioned in the comments the solution could be to embed a manifest in the executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With