0

I have a batch script that does some clean up, which is installed along the main application. However, I cannot seem to execute the batch file before uninstallation. Here is my install script:

function Component() {

}

function Controller() {
    installer.setDefaultPageVisible(QTInstaller.TargetDirectory, false);
}

Controller.prototype.uninstallationStartedFunction = function() {
    if(systemInfo.productType == "windows") {
        installer.gainAdminRights();
        installer.execute(installer.value("TargetDir") + "/disable.bat");
    }
}

Any help is appreciated.

Compo
  • 36,585
  • 5
  • 27
  • 39
Alp Erbil
  • 11
  • 2
  • You have not shown us what the true value of `"TargetDir"` is, so I would have to assume, that it is not an absolute path, but a relative one. If it is relative it would need to be relative to `C:\Windows\System32`, because that will be the default current directory when the script is run elevated, (as administrator). If on the other hand it is absolute, or correctly invoked as relative, then you may need to ensure that your `disable.bat` is pre defining the current directory it needs, or itself uses absolute paths. – Compo Jul 11 '22 at 17:04

1 Answers1

0

It depends if this is your component script or controller script. You can use the controller script and should connect to the installer signals handle to have a callback function to execute if the uninstallation is running. For example

function Controller() {
   installer.uninstallationStarted.connect(this,Component.prototype.onUninstallationStarted);
}

Component.prototype.onUninstallationStarted = function()
{
   // do your stuff
}
Harut
  • 43
  • 6