Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Using msi files in Qt Framework Installer



  • Hi all,

    I want to use a msi file in my qt installer.

    I added a script to the "installscript.qs". Content of the installscript.qs:

    function Component()
    {
        // default constructor
    }
    
    Component.prototype.createOperations = function()
    {
        // call default implementation
        component.createOperations();
    
        var msiPackage = "@TargetDir@\\setup\\msiPackage.msi";
    
        // install msi package
        component.addOperation( "Execute", "msiexec", [ "/i", msiPackage, "/passive" ], "UNDOEXECUTE", "msiexec", [ "/x", msiPackage, "/passive" ] );
    }
    

    The path for the msi file is:

    C:\Program Files\MyCompany\MyApplication\setup\msiPackage.msi"
    

    Unfortunately, the path contains spaces.
    What I don't understand is, that it works when the msi package is installed by the qt installer (even with spaces), but uninstall does not work because of the following error:

    Execution failed (Unexpected exit code: 1619): "msiexec /x C:\Program Files\MyCompany\MyApplication\setup\msiPackage.msi /passive"
    

    It is working (both install and uninstall) when the path does not contain any spaces.

    Even settings the path of the msiPackage into quotes does not work.

    var msiPackage = "\"@TargetDir@\\setup\\msiPackage.msi\"";
    

    Can someone help me?

    regards
    Oliver



  • @stvokr
    In principle you need to quote the path with spaces by the time it gets executed as an OS command. I don't use this stuff, but there seems to be a discrepancy in your code:

    component.addOperation( "Execute", "msiexec", [ "/i", msiPackage, "/passive" ], "UNDOEXECUTE", [ "msiexec", "/x", msiPackage, "/passive" ] );
    

    In the first half, the misiexec is outside of the [ ... ] list. In the second half the misiexec is inside of the [ ... ] list. Why is this? Is there any relation to the command-line then generated?

    Further, you say the uninstall does not work and the message shows the install line (/i instead of /x). Is that an issue?



  • @JonB

    1. This is in error, the paranthesis is wrong.

    2. This is also an error, a stupid typing error.

    I changed the first post.



  • @stvokr
    Then I'm afraid I don't know. I would have thought you need to quote the path as you showed in your attempt. Really this would apply to any command, nothing special about msiexec. Are you sure this does not work?

    Otherwise, the last example on https://doc.qt.io/qtinstallerframework/scripting.html uses @TargetDir@ and claims to work for C:\Program Files without quoting. And https://doc.qt.io/qtinstallerframework/operations.html example:

    Example: component.addOperation("Execute", "touch", "test.txt", "UNDOEXECUTE", "rm", "test.txt")
    

    does not use your [ ... ] syntax, and you have just the maximum 10 arguments to still fit.



  • I have a solution, but I don't know if this is the best solution.

    You can uninstall a msi package with the productcode, in this case it is

    component.addOperation( "Execute", "msiexec", [ "/i", msiPackage, "/passive" ], "UNDOEXECUTE", "msiexec", [ "/x", "{0F1B057A-20E6-4D53-A523-B32B2B1B8987}", "/passive" ] );
    

    But I don't know windows product codes. Are they unique so you can use this number on any computer?



  • @stvokr
    I think the product code is specified in the original msiexec package you installed, i.e. it's a resource in the .msi file. Then it may or may not change as new versions of that .msi are produced.


Log in to reply