Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Requesting administrator rights on Windows 8 is not working
Forum Update on Monday, May 27th 2025

[SOLVED] Requesting administrator rights on Windows 8 is not working

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 7.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qub1
    wrote on last edited by
    #1

    Hello,

    I'm using the following line in my .pro file to make the program request admin rights:
    @QMAKE_LFLAGS += /MANIFESTUAC:"level='requireAdministrator' uiAccess='false'"@

    However, when the program is compiling I get the following error:
    :-1: error: error: /MANIFESTUAC:level='requireAdministrator' uiAccess='false': No such file or directory

    Are there any additional steps I'm missing? I've tried cleaning the project and running qmake without success.

    Thanks!

    1 Reply Last reply
    0
    • hskoglundH Online
      hskoglundH Online
      hskoglund
      wrote on last edited by
      #2

      Hi it sure looks correct to me. I just tried a new empty Widgets app, added your QMAKE_LFLAGS at the end of the .pro file, and sure enough Windows displays the UAC prompt when I start the app.

      My setup: 32-bit Qt 5.3.2 on Visual Studio 2013 Update 3 on 64-bit Windows 8.1. Perhaps you're using MinGW?

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qub1
        wrote on last edited by
        #3

        Yes I am, I've just left it as default. Do I need to switch?

        1 Reply Last reply
        0
        • hskoglundH Online
          hskoglundH Online
          hskoglund
          wrote on last edited by
          #4

          Yeah, it seems the MinGW toolchain (specifically ld.exe) doesn't support stuffing a custom Windows manifest into the .exe file, you could do it manually using a hex editor or you could switch to Visual Studio.

          1 Reply Last reply
          0
          • Chris KawaC Online
            Chris KawaC Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            With mingw you need to create app manifest requiring elevated rights by hand and either embed it after the creation of exe with a third party tool (eg. mt.exe from Microsoft) or as a resource (.res, not the .qrc of Qt ). I wouldn't go as far as stuffing it with hex editor but I can imagine there are people who do :)

            "Here":http://msdn.microsoft.com/en-us/library/windows/desktop/bb756929.aspx is an example manifest and the command line for mt.exe (near the bottom of the article):

            1 Reply Last reply
            0
            • hskoglundH Online
              hskoglundH Online
              hskoglund
              wrote on last edited by
              #6

              You younger people, always lazy using a tool (mt.exe) when instead you can be a real man and fire up a hex editor.

              Just kidding! Thanks Chris, I should have guessed there was a handy tool available. Perhaps possible to include in QtCreator's build process?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Could be the subject of a feature request ;)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • hskoglundH Online
                  hskoglundH Online
                  hskoglund
                  wrote on last edited by
                  #8

                  Indeed SGaist, it's a good idea, it would increase the value of the MinGW toolchain as used by Qt.

                  (You can of course add the invocation of mt.exe as a custom process step to be run after mingw32-make.exe yourself, but if it's a built-in feature so much better. Also it could be used for Visual Studio installations as well, then you wouldn't have to include that QMAKE_LFLAGS line shown above.)

                  Finally, I think for manifests to work 100% with mingw, it needs to loose its "dependency on msvcrt.dll":http://blogs.msdn.com/b/oldnewthing/archive/2014/04/11/10516280.aspx.

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    Qub1
                    wrote on last edited by
                    #9

                    Thanks for all the suggestions!

                    I've switched to the MSVC compiler and it is working now, however a built-in tool to do this would definitely be useful!

                    Consider this solved :)

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      I'll let you guys create the request since you already have the complete process at hand that could be added to Qt Creator

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • Chris KawaC Online
                        Chris KawaC Online
                        Chris Kawa
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        I don't think that's a good idea. mt.exe is part of the MS toolchain and the whole idea of MinGW is to use an alternative. If you install MS toolchain you might as well use MSVC and avert the whole thing.

                        Apps requiring admin rights are not (or rather should not be) that common and, as I said, you can also just embed the manifest in the resource file (which you will probably create on Windows anyway, if only for the exe icon and version info).

                        @hskoglund - the msvcrt debate is as long as the history of MinGW itself. I wish this could be fixed but either side wasn't willing to do that for years - MS won't finally remove the file from the OS because of backwards compatibility and MinGW won't stop using it because they didn't port libc to Windows yet (it's been like that for years now).
                        The MinGW toolchain is lacking a lot in my opinion. Few tools, codegen of MSVC is better, the std library issue... The only argument to use it I can think of is better C++11/14 support.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved