Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess, osascript, and administrator privileges
Qt 6.11 is out! See what's new in the release blog

QProcess, osascript, and administrator privileges

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wesblake
    wrote on last edited by wesblake
    #1

    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);
            //p.write(aScript.toUtf8());
            p.closeWriteChannel();
            p.waitForFinished();
            //int retVal = QProcess::execute("osascript", QStringList() << "-e" << "do shell script \"sudo installer -verbose -store -pkg "+filePath+" -target /\" with administrator privileges");
            //if(retVal>-1)
                //slotReboot();
    

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wesblake
        wrote on last edited by
        #3

        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. :)

        mrjjM 1 Reply Last reply
        1
        • W wesblake

          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. :)

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved