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. QtIFW: Mkdir and Delte does not work at C:
Forum Updated to NodeBB v4.3 + New Features

QtIFW: Mkdir and Delte does not work at C:

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

    Hi,

    i want to install my application under C:\Program Files\myapp. The follwing code will create the directory "webservices" automatically.

    Component.prototype.createOperationsForArchive = function(archive) {	
    	component.addOperation("Extract", archive, "@TargetDir@/webservices");
    }
    

    But if i want to create and delete a folder like this:

    var dir = installer.value("TargetDir");	
    	component.addElevatedOperation("Delete", dir + "/webservices");
    

    or use the installer

    if(installer.isInstaller()){		
    		if(installer.fileExists(dir +"/tmp") == true){			
    			installer.performOperation("Delete", "@TargetDir@/tmp");					
    		}	
    	}
    

    it will not work.

    If i use another installation directory like C:\Users it will work witouht Problems.

    How can i create and delete files under C:?

    best regard and thank you for your help in advance

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You need administrator permissions to modify C:/ on modern Windowses.

      (Z(:^

      1 Reply Last reply
      4
      • S Offline
        S Offline
        Schenk
        wrote on last edited by
        #3

        @Schenk said in QtIFW: Mkdir and Delte does not work at C::

        addElevatedOperation

        I thought addElevatedOperation gaisn Admin rights?

        sierdzioS 1 Reply Last reply
        0
        • S Schenk

          @Schenk said in QtIFW: Mkdir and Delte does not work at C::

          addElevatedOperation

          I thought addElevatedOperation gaisn Admin rights?

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @Schenk said in QtIFW: Mkdir and Delte does not work at C::

          @Schenk said in QtIFW: Mkdir and Delte does not work at C::

          addElevatedOperation

          I thought addElevatedOperation gaisn Admin rights?

          I don't know. Do you see the popup asking you to grant admin rights when you run your installer?

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Schenk
            wrote on last edited by Schenk
            #5

            Yes, i see it, but it does not work.

            I could get AdminRights on the config script with installer.gainAdminRights() and then work with performOperation(). This works.

            But if i want to delete or move files after installation in the package scripts, it will not work.

            Function registered:

            installer.installationFinished.connect(this, Component.prototype.deleteTempFiles);
            

            Later:

            Component.prototype.deleteTempFiles = function(){
            	var dir = installer.value("TargetDir");	
            	QMessageBox.information("asasas", "asasa", "dir: " + dir, QMessageBox.Ok);
            	installer.gainAdminRights();	
            	
            	//component.addElevatedOperation("Delete", dir + "temp.txt");
            	installer.performOperation("Delete", dir + "temp.txt");
            	
            	installer.dropAdminRights();
            }
            

            Neither component.addElevatedOperation() nor installer.performOperation in combination with gain and dropAdminRights() will not work in package script under C:\Program Files.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Schenk
              wrote on last edited by
              #6

              Ok, i found the solution:

              installer.performOperation("Delete", dir + "/temp.txt"); // the slash was missing
              

              Only this one will work

              Component.prototype.deleteTempFiles = function(){
              	var dir = installer.value("TargetDir");	
              	installer.gainAdminRights();		
              	//component.addElevatedOperation("Delete", dir + "/temp.txt");
              	installer.performOperation("Delete", dir + "/temp.txt");	
              	installer.dropAdminRights();
              }
              

              Try to do an elevated Operation will not work! You have to use the installer-solution.

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

                Curiously, this operation works...

                Component.prototype.createOperations = function()
                {
                    component.createOperations();		
                   component.addElevatedOperation("Execute", "@TargetDir@/foo.exe");	
                }
                
                
                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