Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Installer Framework - Don't uninstall specific files or folders?
Forum Update on Monday, May 27th 2025

Qt Installer Framework - Don't uninstall specific files or folders?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trapezoid_Dreams
    wrote on last edited by
    #1

    This is the most I've been able to find on the topic:
    https://stackoverflow.com/questions/56882558/qt-installer-framework-how-to-delete-only-certain-files-and-folers-at-uninstal
    https://forum.qt.io/topic/105775/ifw-how-did-nt-remove-moved-file-from-simplemovefile-operation-on-uninstalling

    The general concept is, you don't delete everything on uninstall. In my case, I particularly don't want to delete something added through:

    component.addOperation("Mkdir", "MyDirectoryPath");
    

    The point of this is to have "safe" areas the program installs, like some programs do. For example, some games will have a folder section in Documents with your Saves in there. And the Saves stay intact regardless of whether you uinstall or delete the program itself (so you don't lose Saves if you need to reinstall).

    Based on the linked material I've found on this, I'm struggling to figure out how to override registerPathForUninstallation such that something added with (for example) Mkdir as mentioned above, is not included.

    Any ideas?

    (Side note: I noticed that if, after installation, you manually put something in a folder created through addOperation / Mkdir, it will fail to delete the directory on uninstall, but will say there's an error and ask you to retry or ignore. I gather this has to do with what I've read about it not deleting things if the installer didn't add them. But I'd rather people not be confronted with an error message and think there's a problem, and I'd rather it didn't even try to delete things I don't want it to.)

    For reference, this is what my installscript.qs looks like:

    function Component()
    {
    }
    
    Component.prototype.createOperations = function()
    {
        component.createOperations();
        if (installer.value("os") === "win") 
        {
            component.addOperation("CreateShortcut", "@TargetDir@/MyAppName.exe", "@DesktopDir@/MyAppName.lnk");
            component.addOperation("CreateShortcut", "@TargetDir@/MyAppName.exe", "@StartMenuDir@/MyAppName.lnk");
            component.addOperation("Mkdir", "@HomeDir@/Documents/MyAppName");
        }
    }
    
    1 Reply Last reply
    0
    • T Offline
      T Offline
      Trapezoid_Dreams
      wrote on last edited by
      #2

      Related to this, does anyone know how to do the Registering Custom Operations step as outlined here? https://doc.qt.io/qtinstallerframework/scripting.html

      It doesn't say anything I can find as to where the class code goes, so that your custom operation is usable in the installer. I tried putting it in the installscript.qs, but it just gives me syntax errors, so I'm guessing that's not the place for it. It looks like the kind of code you'd put in .h and .cpp files, respectively, but I have no idea where you'd put those files for it to be recognized in the installer.

      The idea is that if I could register a custom operation with the "undo" part blank, maybe it won't remove the stuff created through that operation on uninstall. Could be a silly idea, but I can't try it unless I can figure out how to register a custom operation.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mohiwoods
        wrote on last edited by Mohiwoods
        #3

        Could you find a solution to this? I have the same issue as well couldn't figure out a solution
        @Trapezoid_Dreams

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved