To understand how I use the software:
When starting the installer, the user can choose whether to install or update the software. If he installs the software with the install option, then the software can also be uninstalled regularly via the uninstaller.
I now also misuse the installation function as an update function. Here let's distinguish between the normal upgrade function of Inno Setup and my created update option via code. The update option is nothing more than a normal installation. However, the user must specify any paths to the pre-installed software beforehand. This has to do with the fact that most of our users have already installed the software manually before. (Java, Tomcat and our web application). The normal installation and my specially created update option work fine so far.
By means of registry entries set during installation or update, I can distinguish whether the software has been installed or updated using the "Installer" or "Updater" option.
If the user has now installed the software via the normal installation option, then it should be possible to uninstall it completely. This means that the (Inno Setup) Uninstaller should delete all files. However, this should not be the case if the user uses the update option. The update function works by backing up some files before the regular installation, deleting unnecessary files using DelTree
, and then letting the installation recreate them.
Is it possible to set a condition so that the uninstaller does not delete these files in the Files
section if the user has previously used the Update option?
Normally, of course, the uninstaller should delete these files if the user has previously installed the software using the install option. However, I would like these files not to be deleted if the user has previously selected the update option in the installer.
The following is a brief portion of my options:
[Setup]
UninstallFilesDir={code:UnInstallerPath}
[Files]
Source: "<source>\Tomcat9\*"; DestDir: "{code:GetTomcatSourcepath}"; Excludes: "webapps"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\{#JAVA}\*"; DestDir: "{code:GetJAVAExtractpath}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\Tomcat9\webapps\ROOT\*"; DestDir: "{code:GetWebAppSourcepath}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\config\*"; DestDir: "{code:GetConfigInstallPath}"; Check: IsInstaller; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\libraries\{#DLLFile}"; DestDir: "{code:GetConfigInstallPath}"; Flags: ignoreversion
[UninstallDelete]
Type: filesandordirs; Name: "{code:GetUninstallPath}"; Check: IsInstalledviaProgram;
Type: filesandordirs; Name: "{code:UnInstallerPath}";
So the uninstaller should not delete any files other than its own exe and the associated data file if the installer was only used for the update using my created update function.
Due to the fact that I want to be able to uninstall the application if it was previously installed by the installation option, I unfortunately cannot use the uninsneveruninstall
flag.
For better understanding, you can see in the following picture the first page that is displayed after starting the installer.
All Check
functions (including those in the UninstallDelete
section are evaluated on install time. Not on uninstall time.
Based on the name of your IsInstalledviaProgram
function, I guess that it is implemented in a way to work in the uninstaller (by checking the registry entries?). But it is actually executed during the installation. So you should check for the radio buttons, not the registry entries (whose state at the time the function is called likely do not correspond yet). Maybe the IsInstaller
is the function you should use.