QProcess, osascript, and administrator privileges

  • Re: MacOS: how to run AppleScript script from a Qt app?

    Hello. I'm trying to build in an app updater. We want to download and run pkg's as store for later connection to store (so we can move our app when we're off webkit)

    Here's the code:

    QString aScript =
            "do shell script quot;installer -verbose -store -pkg "+filePath+" -target /quot;"
            " with administrator privileges";
            QString osascript = "sudo /usr/bin/osascript";
            QStringList processArguments;
            processArguments << "-e" << "do shell script \"installer -verbose -store -pkg "+filePath+" -target /\" with administrator privileges";
            QProcess p;
            p.start(osascript, processArguments);
            //int retVal = QProcess::execute("osascript", QStringList() << "-e" << "do shell script \"sudo installer -verbose -store -pkg "+filePath+" -target /\" with administrator privileges");

    As you can see, I've tried a couple different ways. The issue is this actually works great when I run the app from Xcode/Qt Creator. However, when I archive and install the signed app, it just stops at this command and never shows the gui prompt for password. Ideas?

  • Lifetime Qt Champion


    What about using an existing framework for that like Sparkle or KDAB's KDUpdater ?

  • Not sure how to mark solved, but I solved it. It was sandboxing that was preventing anything sudo to run. Turned off sandbox and it works fine. :)

  • Qt Champions 2017

    On the first post, under it, there is a button called Topic tools. it has the Solved menu.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.