Results 1 to 6 of 6

Thread: How to run application in qt as administrator?

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to run application in qt as administrator?

    How to run application in Qt as administrator? After build, instead of right click and run as administrator everytime. Once the build is over, if we just double click the app.exe. It should run as administrator automatically...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to run application in qt as administrator?

    For Windows you embed an application manifest specifying the required requestedExecutionLevel. You will not avoid the UAC prompt if that is what you are hoping for. If you application needs to display anything in the GUI I think you also have to sign it.

    For Mac. Don't know.

  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to run application in qt as administrator?

    How to do the same using Mingw?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to run application in qt as administrator?

    The same way. You write your manifest XML file, include the relevant entry in your application's RC file, and rebuild your application.

    Your PRO file:
    Qt Code:
    1. ...
    2. RC_FILE = coolapp.rc
    3. ...
    To copy to clipboard, switch view to plain text mode 

    Your coolapp.rc file:
    Qt Code:
    1. #include <windows.h>
    2.  
    3. ID_ICON ICON DISCARDABLE "coolapp_desktop.ico"
    4. CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "coolapp.exe.manifest"
    To copy to clipboard, switch view to plain text mode 

    Your manifest file (coolapp.exe.manifest):
    Qt Code:
    1. <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    2. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    3. <assemblyIdentity version="2.0.0.0" processorArchitecture="X86"
    4. name="gokulnathvc.coolapp" type="win32" />
    5. <description>Gokulnathvc Really Cool App</description>
    6. <dependency />
    7. <!-- Identify the application security requirements. -->
    8. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    9. <security>
    10. <requestedPrivileges>
    11. <requestedExecutionLevel
    12. level="asInvoker"
    13. uiAccess="false"/>
    14. </requestedPrivileges>
    15. </security>
    16. </trustInfo>
    17. <!-- padding to four-byte multiple file size including the byte order mark -->
    18. <!-- padding 123 -->
    19. </assembly>
    To copy to clipboard, switch view to plain text mode 
    You will need to adapt that manifest to set the requested execution level. (You can probably ignore the comment about padding, it works around a bug with early compilers the specifics of which I cannot quite remember)

  5. The following user says thank you to ChrisW67 for this useful post:

    Gokulnathvc (20th January 2012)

  6. #5
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to run application in qt as administrator?

    Shall we do that in project settings. instead of doing that out side.. possibility of doing that as post build.

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to run application in qt as administrator?

    Was there a question in there somewhere?

Similar Threads

  1. Replies: 1
    Last Post: 12th November 2011, 15:50
  2. Replies: 3
    Last Post: 28th October 2011, 23:24
  3. Replies: 2
    Last Post: 21st November 2010, 18:03
  4. Replies: 3
    Last Post: 6th January 2010, 16:55
  5. Replies: 3
    Last Post: 13th December 2008, 10:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.