0

I create a application using qt installer framework. Now uninstalling my app does not remove AppData/Roaming/My app folder. So i tried my custom code for uninstall to clear my AppData. But this makes my installer unresponsive.

Controller.prototype.FinishedPageCallback = function() {

if (installer.isUninstaller() && installer.status == QInstaller.Success)  
     {    
            var appDataPath = QDesktopServices.storageLocation(QDesktopServices.AppDataLocation) + "\\My app";



         if(installer.fileExists(appDataPath) === true)    
         {
                installer.executeDetached("cmd",["/c", "rd", "/q", "/s", appDataPath]);
         }

            gui.clickButton(buttons.FinishButton);
    }  
}

I also tried using

if(installer.runUninstall === true)    

     { 
         installer.performOperation("Execute" , "cmd" "C:/Users/%USERNAME%/AppData/Roaming/My App", "rd", "/s", "/q");  
     }

Does not work either. Am I missing something?

Rubina
  • 123
  • 1
  • 17

3 Answers3

1

After testing with the installer operations found that Rmdir/ Execute does not work as expected . But delete operation worked for me.

installer.performOperation("Delete","@HomeDir@/AppData/Roaming/My App/myfile.txt");  
Rubina
  • 123
  • 1
  • 17
  • Great! I have tried with component. It doesn't work. – Hareen Laks Jun 05 '20 at 11:29
  • I'm creating an IFW installer using CMake and need to put my files in %APPDATA% as I'm installing a plug-in into another application. `@HomeDir@` works perfectly! `set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/AppData/Roaming/Application/Plugins/MyPlugin")` – thomasa88 Nov 05 '21 at 07:01
0

I guess the culprit is the space between 'My' and 'App'. Provide quotes within the string:

"\"C:/Users/%USERNAME%/AppData/Roaming/My App\""
Heri
  • 4,368
  • 1
  • 31
  • 51
0

There is a good hint in this answer. To allow remove the directories created by the installer and updated than it should be registerPathForUninstallation method used with parameter boolean wipe = true, check more in documentation. So the script to create the installer may look as follows:

function Component()
{
    // default constructor
    var programFiles = installer.environmentVariable("ProgramFiles");   
    if (programFiles != ""){
         installer.setValue("TargetDir", programFiles + "/My app");
    }
    var appDataRoaming = installer.environmentVariable("AppData");     
    if (appDataRoaming != ""){
        installer.setValue("DataDir", appDataRoaming + "/My app");
    }
    component.registerPathForUninstallation("@DataDir@", true);
}

Component.prototype.createOperations = function()
{
    try {
        // call the base create operations function
        component.createOperations();
        if (installer.value("os") == "win") { 
            try {
                component.addOperation("CreateShortcut", "@TargetDir@/My app.exe", "@StartMenuDir@/My app.lnk", "workingDirectory=@TargetDir@");                
                component.addOperation("Mkdir", "@DataDir@");
            } catch (e) {
                // Do nothing if key doesn't exist
            }
        }
    } catch (e) {
        print(e);
    }     
}
abaghiyan
  • 141
  • 1
  • 4