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. Qt Installer Framework: Spaces in target paths (Windows7-64)
Forum Updated to NodeBB v4.3 + New Features

Qt Installer Framework: Spaces in target paths (Windows7-64)

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
spaces in pathsinstallerwin64
9 Posts 4 Posters 4.2k 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.
  • P Offline
    P Offline
    Peter.Chorn
    wrote on 29 Feb 2016, 10:52 last edited by
    #1

    Hello!
    I have to install postgeSQL along with my app as a component with its own database-path. So the user has to enter two target paths, one for the app (targetDir) and one for the database location (dbTargetDir). I have used the dynamic-page-example from the tutorial. The db-installation is done with a bat-file which accepts the dbTargetDir as a parameter.
    If just one (or none) of the paths contains a space everything is OK but if both paths contains spaces I got the error:

    Error on Installing the component ORG.POSTGRESQL:
    Execution failed (unexpected error code 1): "cmd /C D:\my app dir\install_pg.bat D:\temp\my pg dir"

    I have tried adding double quotes to the path variables but it didn't help. The to be called install_pg.bat just echoes the given parameter. so the bat file is OK.

    Here is the relevant install script code snippet:

    Component.prototype.createOperations = function()
    {
    component.createOperations();

    if (systemInfo.productType === "windows") 
    {	
    	var targetExe = Dir.toNativeSeparator(installer.value("TargetDir") + "/install_pg.bat");
    	var dbTargetDir = Dir.toNativeSeparator(installer.value("dbTargetDir"));
    	var workingDir = Dir.toNativeSeparator(installer.value("TargetDir"));
    

    /* this does not help!! :
    if (targetExe.indexOf(' ') !== -1)
    {
    if (dbTargetDir.indexOf(' ') !== -1)
    {
    dbTargetDir = """+dbTargetDir+""";
    targetExe = """+targetExe+""";
    workingDir = """+workingDir+""";
    }
    }
    QMessageBox.information("info", "targetExe", "targetExe="+targetExe,QMessageBox.Ok);
    QMessageBox.information("info", "dbTargetDir", "dbTargetDir="+dbTargetDir,QMessageBox.Ok);
    QMessageBox.information("info", "workingDir", "workingDir="+workingDir,QMessageBox.Ok);
    */

        component.addElevatedOperation("Execute", "cmd", "/C", targetExe, dbTargetDir, "workingDirectory="+workingDir);
    }
    

    }

    I am thankfull for any suggestions/ideas that I may try!
    Best Regards,
    Peter

    M 1 Reply Last reply 15 Nov 2018, 14:31
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 29 Feb 2016, 12:18 last edited by
      #2

      Do it like this:

      dbTargetDir = "\""+dbTargetDir+"\"";
      targetExe = "\""+targetExe+"\"";
      workingDir = "\""+workingDir+"\"";
      

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

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 29 Feb 2016, 12:20 last edited by
        #3
        """" - this means two empty strings which are just concatenated
        

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

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Peter.Chorn
          wrote on 29 Feb 2016, 14:42 last edited by
          #4

          Thanks for the answer, but there were originally 'double quotes + backslash +double quotes + double quotes' . Somehow the copy-paste killed my backslashes.

          Anyway, when I had done that there was a slightly different error message:

          Error while installing component ORG.POSTGRESQL:
          Execution failed: 'cmd /C "d:\my app di\install_pg.bat" "d:\temp\my pg dir"'.
          Errormessage: The execution of the process failed: The directory name is invalid.
          

          I have also tried just to quote targetExe and dbtargetDir and not the workingDir (or just targetExe, or just dbTargetDir or any other combinations of the three paths). This failed also with the error message.
          Any suggestions are highly appreciated!

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 1 Mar 2016, 05:20 last edited by
            #5

            Are you sure both directories exist?
            What happens if you try to execute same command directly in a cmd window?
            In any case you should avoid using directory names with blanks - else you will often have problems like this.

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

            P 1 Reply Last reply 1 Mar 2016, 09:23
            0
            • J jsulm
              1 Mar 2016, 05:20

              Are you sure both directories exist?
              What happens if you try to execute same command directly in a cmd window?
              In any case you should avoid using directory names with blanks - else you will often have problems like this.

              P Offline
              P Offline
              Peter.Chorn
              wrote on 1 Mar 2016, 09:23 last edited by
              #6

              @jsulm

              Only the targetExe and workingDir must exist (and they do).
              The dbTargetDir may or may not exist. This is only handled by the install_pg.bat-file. Qt-IFW should handle this parameter only as a string with spaces inside. Maybe it doesn't do that and it checks it for existence?
              Anyway, even if all path-parameters exists, the error shows up.

              It would help much if someone did the same (or similar) thing: called addElevatedOperation with a bat-file with spaces in the path and with an additional path-parameter also with spaces and also supplied the workingDir (again with spaces). Did anyone do that and did it work?

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Peter.Chorn
                wrote on 1 Apr 2016, 11:48 last edited by
                #7

                The Qt support gave me this solution which worked on their environment:

                        var targetExe = Dir.toNativeSeparator(installer.value("TargetDir") + "/install_pg.bat");
                		var dbTargetDir = Dir.toNativeSeparator(installer.value("dbTargetDir"));
                		var workingDir = "workingdirectory=" + Dir.toNativeSeparator(installer.value("TargetDir"));
                	   				
                		if (dbTargetDir.indexOf(' ') !== -1)
                		{
                			dbTargetDir = "\""+dbTargetDir+"\"";		
                		}
                		
                		var myArray= ["cmd.exe /C," + targetExe + "," + dbTargetDir];
                        component.addElevatedOperation("Execute",  new Array(myArray),  workingDir);		
                

                Unfortunatelly it didn't work with my environment but others may find it useful!

                1 Reply Last reply
                0
                • P Peter.Chorn
                  29 Feb 2016, 10:52

                  Hello!
                  I have to install postgeSQL along with my app as a component with its own database-path. So the user has to enter two target paths, one for the app (targetDir) and one for the database location (dbTargetDir). I have used the dynamic-page-example from the tutorial. The db-installation is done with a bat-file which accepts the dbTargetDir as a parameter.
                  If just one (or none) of the paths contains a space everything is OK but if both paths contains spaces I got the error:

                  Error on Installing the component ORG.POSTGRESQL:
                  Execution failed (unexpected error code 1): "cmd /C D:\my app dir\install_pg.bat D:\temp\my pg dir"

                  I have tried adding double quotes to the path variables but it didn't help. The to be called install_pg.bat just echoes the given parameter. so the bat file is OK.

                  Here is the relevant install script code snippet:

                  Component.prototype.createOperations = function()
                  {
                  component.createOperations();

                  if (systemInfo.productType === "windows") 
                  {	
                  	var targetExe = Dir.toNativeSeparator(installer.value("TargetDir") + "/install_pg.bat");
                  	var dbTargetDir = Dir.toNativeSeparator(installer.value("dbTargetDir"));
                  	var workingDir = Dir.toNativeSeparator(installer.value("TargetDir"));
                  

                  /* this does not help!! :
                  if (targetExe.indexOf(' ') !== -1)
                  {
                  if (dbTargetDir.indexOf(' ') !== -1)
                  {
                  dbTargetDir = """+dbTargetDir+""";
                  targetExe = """+targetExe+""";
                  workingDir = """+workingDir+""";
                  }
                  }
                  QMessageBox.information("info", "targetExe", "targetExe="+targetExe,QMessageBox.Ok);
                  QMessageBox.information("info", "dbTargetDir", "dbTargetDir="+dbTargetDir,QMessageBox.Ok);
                  QMessageBox.information("info", "workingDir", "workingDir="+workingDir,QMessageBox.Ok);
                  */

                      component.addElevatedOperation("Execute", "cmd", "/C", targetExe, dbTargetDir, "workingDirectory="+workingDir);
                  }
                  

                  }

                  I am thankfull for any suggestions/ideas that I may try!
                  Best Regards,
                  Peter

                  M Offline
                  M Offline
                  martonmiklos
                  wrote on 15 Nov 2018, 14:31 last edited by
                  #8

                  @Peter.Chorn

                  How did you managed to import the Dir component?

                  D 1 Reply Last reply 15 Feb 2019, 13:52
                  0
                  • M martonmiklos
                    15 Nov 2018, 14:31

                    @Peter.Chorn

                    How did you managed to import the Dir component?

                    D Offline
                    D Offline
                    Dilshod Mukhtarov
                    wrote on 15 Feb 2019, 13:52 last edited by
                    #9

                    @martonmiklos said in Qt Installer Framework: Spaces in target paths (Windows7-64):

                    @Peter.Chorn

                    How did you managed to import the Dir component?

                    In QIF 3 dynamic page example, there is the following definition (installscript.js):

                    var Dir = new function () {
                        this.toNativeSparator = function (path) {
                            if (systemInfo.productType === "windows")
                                return path.replace(/\//g, '\\');
                            return path;
                        }
                    };
                    
                    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