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



  • 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


  • Moderators

    Do it like this:

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

  • Moderators

    """" - this means two empty strings which are just concatenated
    


  • 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!


  • Moderators

    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.



  • @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?



  • 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!


Log in to reply
 

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