Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to set access rights in folders with the Qt Installer Framework
Forum Updated to NodeBB v4.3 + New Features

How to set access rights in folders with the Qt Installer Framework

Scheduled Pinned Locked Moved Solved Installation and Deployment
7 Posts 2 Posters 2.4k Views
  • 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.
  • S Offline
    S Offline
    stvokr
    wrote on last edited by stvokr
    #1

    Hi everyone,

    I'm trying to use the Installer Framework on Windows to install my app to "C:\Program Files\My Company\MyApp".
    And my App uses some config files (read and write) in "C:\ProgramData\My Company\MyApp", so I want to create this folder and set the access rights.

    No I have the problem, that the folder should remain, even after uninstalling the software.

    1. This is working, but the folder is deleted during uninstall.

      var dataDir = "C:\ProgramData\My Company\MyApp";
      component.addOperation( "Mkdir", dataDir );
      
    2. This does not work in any configuration, I even tried without spaces in the folder name.

      var dataDir = "C:\ProgramData\My Company\MyApp";
      component.addOperation( "Execute", "mkdir " + dataDir, "UNDOEXECUTE" );
      // or this one
      component.addOperation( "Execute", "mkdir", dataDir, "UNDOEXECUTE" );
      

      I get the following errors:

      • Cannot start: "mkdir C:\ProgramData\My Company\MyApp": Process Failed to start: No such file or directory
      • Cannot start: "mkdir C:\ProgramData\My_Company\MyApp": Process Failed to start: No such file or directory
    3. I also tried a batch file to call mkdir, and this is working. But I want to know if there is a better way from inside the installer to create a folder with spaces in the folder name, which is not beeing deleted during uninstall?

    regards
    Oliver

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stvokr
      wrote on last edited by stvokr
      #2

      I found part of a solution myself.
      This is working when the folder name does not contain spaces.

      installer.executeDetached( "cmd", "/C mkdir C:\\ProgramData\\My_Company\\MyApp", "@TargetDir@" );
      

      A solution with spaces is still required.

      jsulmJ 1 Reply Last reply
      0
      • S stvokr

        I found part of a solution myself.
        This is working when the folder name does not contain spaces.

        installer.executeDetached( "cmd", "/C mkdir C:\\ProgramData\\My_Company\\MyApp", "@TargetDir@" );
        

        A solution with spaces is still required.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #3

        @stvokr You need to put the path into "" to make sure it works with paths containing spaces.

        installer.executeDetached( "cmd", "/C mkdir \"C:\\ProgramData\\My_Company\\MyApp\"", "@TargetDir@" );
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply
        2
        • jsulmJ jsulm

          @stvokr You need to put the path into "" to make sure it works with paths containing spaces.

          installer.executeDetached( "cmd", "/C mkdir \"C:\\ProgramData\\My_Company\\MyApp\"", "@TargetDir@" );
          
          S Offline
          S Offline
          stvokr
          wrote on last edited by
          #4

          @jsulm I forgot to mention, that I already tried masking the quotes. That did not work.

          jsulmJ 1 Reply Last reply
          0
          • S stvokr

            @jsulm I forgot to mention, that I already tried masking the quotes. That did not work.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @stvokr According to https://doc.qt.io/qtinstallerframework/scripting-installer.html#executeDetached-method it is actually not needed: "Windows: Arguments that contain spaces are wrapped in quotes.".
            There is something you're doing wrongly I think. Take a look at this:

            boolean executeDetached(string program, stringlist arguments = undefined, string workingDirectory = "")
            

            The parameters must be passed as a string list. You're passing all parameters as one string.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply
            2
            • jsulmJ jsulm

              @stvokr According to https://doc.qt.io/qtinstallerframework/scripting-installer.html#executeDetached-method it is actually not needed: "Windows: Arguments that contain spaces are wrapped in quotes.".
              There is something you're doing wrongly I think. Take a look at this:

              boolean executeDetached(string program, stringlist arguments = undefined, string workingDirectory = "")
              

              The parameters must be passed as a string list. You're passing all parameters as one string.

              S Offline
              S Offline
              stvokr
              wrote on last edited by
              #6

              @jsulm Hi, if I pass the parameters a string list

              installer.executeDetached( "cmd", "/C", "mkdir", "My_Complany", "C:\\ProgramData\\" ) );
              

              the InstallationLog.txt tells me,

              "run application as detached process: "cmd" ("/C") "mkdir"
              

              and that the operation has returned false. So the given parameter "My_Company" has somehow not been passed.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                stvokr
                wrote on last edited by
                #7

                So, finally, I got a solution (even 2 solutions):

                brackets.

                installer.executeDetached( "cmd", ["/C", "mkdir", "C:\\ProgramData\\My Company\\MyApp"], "C:\\ProgramData" );
                

                With this trick even the addOperation() function works fine:

                component.addOperation( "Execute", "cmd", ["/C", "mkdir", C:\\ProgramData\\My Company\\MyApp"] );
                

                I think this is closed.

                1 Reply Last reply
                2

                • Login

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