Results 1 to 3 of 3

Thread: QProcess::startDetached and UAC on Vista

  1. #1
    Join Date
    Oct 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QProcess::startDetached and UAC on Vista

    Hello.

    The problem: I've got a software update issue on Windows Vista.

    I try to launch the updater for this software with QProcess::startDetached() from the application before closing it.

    Works perfectly on XP when the application was launched by an administrator, but on Vista running the updater requires admin rights, and if the UAC is enabled (default behaviour on Vista) the startDetached method fails.

    How can I solve this ?

    Thanks.

    --
    Jack.

  2. #2
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    1
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4

    Default Re: QProcess::startDetached and UAC on Vista

    did you find out how ?

  3. #3
    Join Date
    Jul 2010
    Location
    Ahmedabad,Gujarat,India
    Posts
    25
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QProcess::startDetached and UAC on Vista

    Go thru this post http://codeblog.vurdalakov.net/2010/...ed-cannot.html

    try below code:


    #ifdef Q_OS_WIN
    #include <windows.h>
    #include <shellapi.h>
    #endif

    /.../

    QString exeFileName;

    /.../


    #ifdef Q_OS_WIN
    int result = (int)::ShellExecuteA(0, "open", exeFileName.toUtf8().constData(), 0, 0, SW_SHOWNORMAL);
    if (SE_ERR_ACCESSDENIED == result)
    {
    // Requesting elevation
    result = (int)::ShellExecuteA(0, "runas", exeFileName.toUtf8().constData(), 0, 0, SW_SHOWNORMAL);
    }
    if (result <= 32)
    {
    // error handling
    }
    #else
    if (!QProcess::startDetached(exeFileName))
    {
    // error handling
    }
    #endif

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.