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:
Code:
QString cmd
= "installer -pkg MY_APP.mpkg -target LocalSystem";
proc->start(cmd);
if (!proc->waitForFinished())
qDebug() << "install failed:" << proc->errorString();
else
qDebug() << "install output:" << proc->readAll();
delete proc;
the result is: install output: "installer: Must be run as root to install this package."
so i changed the code to like this:
Code:
QString cmd
= "sudo installer -pkg MY_APP.mpkg -target LocalSystem";
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.
Re: how to get root privilege for QProcess to run installer on Mac
Quote:
(...) just like double-clicked a mpkg
I've never tried that on mac, but maybe this will work:
quote from QDesktopServices docs:
Quote:
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.
Re: how to get root privilege for QProcess to run installer on Mac
Quote:
Originally Posted by
stampede
I've never tried that on mac, but maybe this will work:
quote from QDesktopServices docs:
It works and it's exactly what I want.Thank you!