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

[Qt Installer Framework] Run a batch file during uninstallation



  • Hi, is there a way to run a batch file during uninstallation of an app created using Qt Installer Framework?


  • Moderators

    Ok, I found the correct file.

    seems like I abandoned the shell script on deinstall and went directly to this entry

    Component.prototype.createOperations = function() {
    ...
    component.addOperation("Execute","echo", "do nothing","UNDOEXECUTE","rm", "-rf", "@HomeDir@/Desktop/MyApp");
    }
    

  • Moderators

    @akhi95 sure

    listen to the uninstallationStarted signal, and connect a function to it. In that function call the script.

    I use it to remove desktop (shortcut) icons on MacOS

    function Component()
    {
    ...
        installer.uninstallationStarted.connect(onUninstallationStarted);
    }
    
    onUninstallationStarted = function()
    {
        var argList = ["@TargetDir@/myApp.app/Contents/MacOS/data/remove-alias.sh"];
        installer.execute("sh",argList);
    }
    


  • @J-Hilk Thanks for the reply. Since an hour, I have been trying to make your code work for my batch script but I'm unable to do so. I'm doing something like this

    function Component()
    {
    ...
        installer.uninstallationStarted.connect(onUninstallationStarted);
    }
    
    onUninstallationStarted = function()
    {
        var argList = ["@TargetDir@/test.bat"];
        installer.execute("bat",argList);
    }
    


  • @akhi95
    Sorry I'm not a "Qt Installer Framework" person, but what is your installer.execute("bat", ...;? bat is no kind of Windows command. If you need something there I would have thought it would likely be one of the following:

    var argList = ["@TargetDir@/test.bat"];
    installer.execute("cmd",argList);
    
    var argList = ["/c", "@TargetDir@/test.bat"];
    installer.execute("cmd", argList);
    
    var argList = [];
    installer.execute("@TargetDir@/test.bat", argList);
    

    ? There ought be Google examples somewhere?


  • Moderators

    @akhi95
    @JonB is correct you will probably want to call the commandpropt for that batch file.

    That said, I may have given you a faulty example. I copy pasted from one I have still on my PC and I struggle to get it to work.

    But I have some google coordinates for you, that may also help:

    https://stackoverflow.com/questions/54810688/uninstall-flow-or-callback-in-qt-installer-framework-3-0-2

    I'll post again, if I manage my example to work as well, it's been over a year for me 🙈


  • Moderators

    Ok, I found the correct file.

    seems like I abandoned the shell script on deinstall and went directly to this entry

    Component.prototype.createOperations = function() {
    ...
    component.addOperation("Execute","echo", "do nothing","UNDOEXECUTE","rm", "-rf", "@HomeDir@/Desktop/MyApp");
    }
    


  • This post is deleted!


  • This post is deleted!


  • @J-Hilk said in [Qt Installer Framework] Run a batch file during uninstallation:

    Ok, I found the correct file.

    seems like I abandoned the shell script on deinstall and went directly to this entry

    Component.prototype.createOperations = function() {
    ...
    component.addOperation("Execute","echo", "do nothing","UNDOEXECUTE","rm", "-rf", "@HomeDir@/Desktop/MyApp");
    }
    

    This worked! Thanks a ton! Initially, I didn't notice the neat little trick you did by doing nothing in the Execute part.


Log in to reply