Results 1 to 3 of 3

Thread: how to get root privilege for QProcess to run installer on Mac

  1. #1
    Join Date
    Apr 2015
    Location
    Beijing,China
    Posts
    6
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question how to get root privilege for QProcess to run installer on Mac

    Hi

    I have a gui app on mac os x which want to do a auto update on start, what i want to do:
    1).download the new mpkg file;
    2).use QProcess to run "installer -pkg MY_APP.mpkg -target LocalSystem" to install the newly downloaded mpkg file;

    my code:
    Qt Code:
    1. QProcess* proc = new QProcess();
    2. QString cmd = "installer -pkg MY_APP.mpkg -target LocalSystem";
    3. proc->start(cmd);
    4. if (!proc->waitForFinished())
    5. qDebug() << "install failed:" << proc->errorString();
    6. else
    7. qDebug() << "install output:" << proc->readAll();
    8. delete proc;
    To copy to clipboard, switch view to plain text mode 
    the result is: install output: "installer: Must be run as root to install this package."
    so i changed the code to like this:
    Qt Code:
    1. QString cmd = "sudo installer -pkg MY_APP.mpkg -target LocalSystem";
    To copy to clipboard, switch view to plain text mode 
    But it didn't work and output nothing.

    What i want is: when proc->start,it will pop up a system gui to let user input passwork,just like double-clicked a mpkg to start a install process.

    I've searched through google and in this forum,but didn't get this solved.
    Can anyone help?
    Thanks in advance.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: how to get root privilege for QProcess to run installer on Mac

    (...) just like double-clicked a mpkg
    I've never tried that on mac, but maybe this will work:
    Qt Code:
    1. QDesktopServices::openUrl(QUrl::fromLocalFile("MY_APP.mpkg"));
    To copy to clipboard, switch view to plain text mode 
    quote from QDesktopServices docs:
    If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser.

  3. #3
    Join Date
    Apr 2015
    Location
    Beijing,China
    Posts
    6
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to get root privilege for QProcess to run installer on Mac

    Quote Originally Posted by stampede View Post
    I've never tried that on mac, but maybe this will work:
    Qt Code:
    1. QDesktopServices::openUrl(QUrl::fromLocalFile("MY_APP.mpkg"));
    To copy to clipboard, switch view to plain text mode 
    quote from QDesktopServices docs:
    It works and it's exactly what I want.Thank you!

Similar Threads

  1. Replies: 5
    Last Post: 30th January 2014, 09:03
  2. Replies: 1
    Last Post: 3rd June 2013, 13:11
  3. root privilege libpcap Elevation Problem mac os x
    By abiusx in forum Qt Programming
    Replies: 0
    Last Post: 24th January 2011, 12:52
  4. Installer UI
    By addu in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2009, 11:53
  5. installer
    By koyot in forum Newbie
    Replies: 1
    Last Post: 26th February 2007, 13:34

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.