Creating a Qt Non-Interactive Uninstaller



  • Currently, I have a non-interactive script I use when installing Qt 5.8, which I call as follows:

    $ sudo ./qt-opensource-linux-x64-5.8.0.run --script qt-noninteractive.qs
    

    The contents of the install script are as follows:

    qt-noninteractive.qs

    function Controller() {
        installer.autoRejectMessageBoxes();
        installer.installationFinished.connect(function() {
            gui.clickButton(buttons.NextButton);
        })
    }
    
    Controller.prototype.WelcomePageCallback = function() {
        gui.clickButton(buttons.NextButton, 3000);
    }
    
    Controller.prototype.CredentialsPageCallback = function() {
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.IntroductionPageCallback = function() {
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.TargetDirectoryPageCallback = function()
    {
        gui.currentPageWidget().TargetDirectoryLineEdit.setText("/opt/Qt5.8.0");
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.ComponentSelectionPageCallback = function() {
        var widget = gui.currentPageWidget();
    
        widget.selectAll();
        widget.deselectComponent('qt.580.src');
        widget.deselectComponent("qt.tools.qtcreator");
    
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.LicenseAgreementPageCallback = function() {
        gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.StartMenuDirectoryPageCallback = function() {
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.ReadyForInstallationPageCallback = function()
    {
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.FinishedPageCallback = function() {
    var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm
    if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) {
        checkBoxForm.launchQtCreatorCheckBox.checked = false;
    }
        gui.clickButton(buttons.FinishButton);
    }
    

    This script runs successfully and the install completes with no issues.

    How would I go about running and creating a corresponding uninstall script?

    Would the call look something like this:

    sudo ./MaintenanceTool --script qt-noninteractive-uninstall.qs
    


  • You could just copy-paste the .qs script you are using for installing and replace the CredentialsPageCallback function with:

    Controller.prototype.CredentialsPageCallback = function()
    {
    var page = gui.pageWidgetByObjectName("CredentialsPage");
    page.loginWidget.EmailLineEdit.setText("email@address");
    page.loginWidget.PasswordLineEdit.setText("foo");
    page.uninstallCheckBox.setChecked(true);
    gui.clickButton( buttons.NextButton);
    }

    Most of the other callbacks are not needed for uninstalling, they can be cleaned up, but it doesn't hurt to have them there either.
    Hope that helps!


Log in to reply