Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Installer.performOperation() to edit and delete a file in installed payload? QT IFW



  • I am trying to edit an installed file during the InstallationFinished stage of my installer. The code I am trying to run looks like this:

    if (installer.value("ExtrasDir") != installer.environmentVariable("PROGRAMDATA")) {
    
        if(installer.performOperation("AppendFile", "factoryExtrasLoc.txt", installer.value("ExtrasDir"))) {
            console.log("We have edited factory locations file.");
        }
    } else {
        if(installer.performOperation("Delete", "factoryExtrasLoc.txt")) {
            console.log("We have deleted factory extras locations file.");
        }
    }
    

    This code runs when InstallationFinished signal is sent. When running with the -v option on the created installer I get this in the output:

    [17473] perform operation: Delete
    [17473] - arguments: factoryExtrasLoc.txt
    [17473] Done
    [17496] We have deleted factory extras locations file.

    but the file is still in the directory of the installed payload. Likewise when I attempt the append file path the output looks like this:

    [19136] perform operation: AppendFile
    [19136] - arguments: factoryExtrasLoc.txt
    [19136] Done
    [19175] undo operation: AppendFile
    [19175] - arguments: factoryExtrasLoc.txt
    [19175] Done

    but my appended text is not within the file. I need to run this operation after extract but it doesn't seem to do what the documentation says:

    boolean performOperation(string name, stringlist arguments)

    Instantly performs the operation name with arguments.

    Am I using this method correctly? Is there a better option to edit a file installed by the installer or delete that file at installer finished?



  • I solved this by placing the code in the correct location in my component script, which is the addOperations() section. I changed the installer.performOperation() to component.addElevatedOperation().


Log in to reply