Applications must be running as administrator. How to ask the user it? How to verify that he agreed? How to find out if applications are already running as administrator, so as not to ask, or it is not necessary?

Did as described here by user ChrisW67. The result is not received. If possible, give an example of a "Hella Vord" project.

PS in the example, and I have architecture 86. At 64, do I need to change something? Windows 7 operating system. I am writing in Qt Creator. Qt5

  • one
    @tioo, well, I should indicate in such a specific issue of the OS . - avp
  • @avp I have windows 7. On linux is also interesting. - Yura712
  • In Windows, I do not know. - And in linux ... The easiest way is to assign (root) the owner: root boot module in advance and set s bits. A.out simple program simply makes the file "xaxa" avp @ avp-ubu1: avparse $ ./a.out uid: 1000 euid: 1000 avp @ avp-ubu1: avparse $ ll xaxa -rw-rw-r-- 1 avp avp 0 May 8 20:01 xaxa avp @ avp-ubu1: avparse $ sudo chown root a.out avp @ avp-ubu1: avparse $ sudo chmod + s a.out avp @ avp-ubu1: avparse $ ./a.out uid: 1000 euid: 0 avp @ avp-ubu1: avparse $ ll xaxa -rw-rw-r-- 1 root avp 0 May 8 20:02 xaxa avp @ avp-ubu1: avparse $ See? - avp
  • @avp, yes, thanks. now Windows. - Yura712
  • If for some reason this is not available, you will have to run through sudo (read man, especially pay attention to the privilege settings in /etc/sudo.conf. Of course, you can change them only by root). If this does not work (well, the root does not want to help you in any way), then look at ssh (only it will have to be run via pty to feed the root password. To simplify programming, see man forkpty ) or su . However, they can be closed for root. Then ... You need to look at the specific configuration (this is like a rootkit to slip into the system). - avp

1 answer 1

What interests you is related to the UAC subsystem and is called elevation . Actually, I suggest to search by these two keywords.

There is also a ready-made example of working with UAC in C ++ on MSDN. I recommend to take a look.

  • 3
    @tioo: By the way, an already running program cannot enhance its rights. You must either launch another copy of the program (as shown in the example), or require rights through manifest (and then they will be available at the very start). There are no other methods under Windows. - VladD