Inno setup script wizard application files screen. Click on the Add files and Add folders option to select the files and folder which are part of the installer for example let there is a folder a and file b,c which are to be added in the installer then these folder and files are browsed and added using this option. After that, you will have a hierarchy like this in Windows Explorer: Editing the ISS script. The.iss file is the Inno Setup script. To edit this file you need to install Inno Setup, which comes with its own script editor. This same editor will be used to compile the new installer at the end of the tutorial.
Delete a file AFTER installation in InnoSetup. I need to delete some files after the installation finishes. Browse other questions tagged file installer inno.
Introduction
Within its lifecycle, an app can create files and folders which may not be of any value to the user once uninstalled. Common practice is to simply ignore the extras and just uninstall what has been installed. Some of the pitfalls of proceeding any further are mentioned in the comments to this answer, yet the code at ISXKB prompted this author to further expand upon the scenario.
Requirements
The reader is best served by having or at least intending to build an active installation with Inno Setup. Very friendly and intuitive interface, along with extensive documentation. Determine where and how files relating to your app are created, and what purpose they will have once the user is no longer using your software.
Using the Code
Download and paste the code in the code section of the .iss script. The dialog driven script is run when the app is uninstalled.
The chief point of interest is at the bottom of the code where paths containing Inno defined constants can be inserted or removed:
The following snippet is for a VB compilation:
The Inno Delete Functions work very well, however they only return false on fail, so we can assume in most situations, the reason is either in-use or not accessible.
If an Updater is used (see below), also consider replicating the above code in the Updater, as depending on the Setup & Updater settings, the code can be removed from the setup uninstall binary (typically unins000.exe) when the Updater executes.
Some of the language dialogs were made with Google Translate so any corrections to them are welcome.
Apologies to non Spanish/German/English subscribers, as those languages were the only ones on offer at ISXKB.
Addendum
The following section is for anyone interested using Inno to update an application. An updater is a separate iss script typically run from {tmp} (inno's temp sub-directory for MyApp prefixed is-.) to update the installation {App} from an external source -e.g. an http server.
Updaters do not have an uninstall as such as they are defined to operate on MyApp
only, but each time an updater is run from {tmp}, any temporary files related to the install session are created in that folder.
In the usual course of installation, these temporary folders are removed after install, but in the case of updating MyApp, Inno (5.59) generates an (Abort-Ignore-Retry) error when attempting to remove an Updater {srcexe} from {tmp} in the ssPostInstall
step with the deleteafterinstall flag thus:
So here's a method to silently remove it after reboot:
Many applications use Inno Setup as their installer format. Extracting and modifying these kind of installers if fairly easy if you know a few things.
I will show you how to extract, modify and recompile an application that uses Inno as its installer.
In this case, I’m going to customize Freemake Video Converter to delete some shortcuts and to avoid the installation of Firefox and Google Chrome extensions. This is being made to suit my personal needs. You may want to keep shortcuts or preserve the extensions. It’s up to you.
Extracting the files
The first thing to do in order to edit the installation files is to extract the files. For this, I use Universal Extractor, which can be downloaded in the Custom Installers downloads page. My installer always includes the latest version of Innounp, which needs to be updated from time to time when new versions of Inno Setup are used in the installer you want to modify.
Open Universal Extractor and select the installer you want to extract and the folder you want to use. After that, you will have a hierarchy like this in Windows Explorer:
Editing the ISS script
The .iss file is the Inno Setup script. To edit this file you need to install Inno Setup, which comes with its own script editor. This same editor will be used to compile the new installer at the end of the tutorial. I prefer to edit the scripts in Notepad++, my favorite text editor. Download my custom installer here.
Open the .iss file in either Inno Setup or any other text editor.
The first thing I do is to set an Icon file for the new setup instead of the default one. To define a new icon file, you need the SetupIconFile command and the path to the .ico file you want to use. This command needs to be placed in the [Setup] section. Freemake uses their own icon, and it’s located inside the Uninstall folder. You can use another one, just make sure to use a fully qualified path to it.
This is how it should look after an icon is set to be used by the compiler:
[iss][Setup]
AppName=Freemake Video Converter
AppVersion=4.0.2
DefaultDirName={pf}Freemake
DefaultGroupName=Freemake
UninstallDisplayIcon={app}Freemake Video ConverterUninstallicon.ico
; Using an icon for the setup file
SetupIconFile={app}Freemake Video ConverterUninstallicon.ico
UninstallFilesDir={app}Freemake Video ConverterUninstall
OutputBaseFilename=Freemake Video Converter 4.0.2.9
Compression=lzma2
DisableProgramGroupPage=yes
WizardImageFile=embeddedWizardImage.bmp
WizardSmallImageFile=embeddedWizardSmallImage.bmp[/iss]
You can read how to modify other things and learn about variables here. I’m editing this application to remove shortcuts and browser extensions only, but feel free to customize anything else if you want.
The next step is to edit the MinVersion variable. As this variable is set for every file in the installer, I will use Find & Replace in Notepad++ to quickly edit all the lines.
Make sure you replace MinVersion: 0.0,5.01.2600 Service Pack 2 with MinVersion: 0.0,5.1.2600 or the compiler will throw an error when compiling your installer.
This particular application uses a variable to set its interface language. As I want it to be shown in Spanish regardless of the language of the computer is it being installed on, I will edit the GetLang function in the [Registry] section. After poking around in the Windows registry, I found that Freemake uses en-US, es-ES and strings like this to set its language. If you don’t modify this entry in the .iss file, you will need to make a script to set it, which is something I will not cover here, or you will see an error while compiling because a script is needed.
Replace this function with the language you want.
[iss][Registry]
Root: HKCU; Subkey: 'SoftwareFreemakeFreemakeVideoConverter'; ValueName: 'Culture'; ValueType: String; ValueData: 'es-ES'; MinVersion: 0.0,5.1.2600;[/iss]
To prevent the browser extensions from being installed you need to delete the following lines.
[iss][Registry]
Root: HKLM; Subkey: 'SoftwareMozillaFirefoxExtensions'; ValueName: 'fmconverter@gmail.com'; ValueType: String; ValueData: '{app}Freemake Video ConverterBrowserPluginFirefox'; Check: 'isInstallBrowserPluginsCheckboxChecked'; MinVersion: 0.0,5.01.2600 Service Pack 2; Flags: uninsdeletevalue
Root: HKLM; Subkey: 'SoftwareGoogleChromeExtensionsjbolfgndggfhhpbnkgnpjkfhinclbigj'; ValueName: 'path'; ValueType: String; ValueData: '{app}Freemake Video ConverterBrowserPluginChromeFreemake.Plugin.Chrome.crx'; Check: 'isInstallBrowserPluginsCheckboxChecked'; MinVersion: 0.0,5.01.2600 Service Pack 2; Flags: uninsdeletevalue
Root: HKLM; Subkey: 'SoftwareGoogleChromeExtensionsjbolfgndggfhhpbnkgnpjkfhinclbigj'; ValueName: 'version'; ValueType: String; ValueData: '1.0.0'; Check: 'isInstallBrowserPluginsCheckboxChecked'; MinVersion: 0.0,5.01.2600 Service Pack 2; Flags: uninsdeletevalue[/iss]
I don’t need a shortcut on the desktop or one to uninstall the application. I will just leave one inside a Freemake folder under All programs in the Start Menu. Delete all the shortcuts you don’t want. This is how my [Icons] section looks like.
[iss][Icons]
Name: '{group}{cm:YTP}'; Filename: '{app}Freemake Video ConverterFreemakeVideoConverter.exe'; WorkingDir: '{app}Freemake Video Converter'; MinVersion: 0.0,5.1.2600;[/iss]
Many installers show checkboxes to perform different actions like running the installed application, placing a desktop shortcut etc. In this case, I will remove two checkboxes to prevent an error in the compiler. This needs to be done because I would need to define functions for these checkboxes to work but as I’m running it with silent switches, I don’t need them.
Search for the Check variable and delete all the entries found. In this case, there are only two. Delete the Check: “isStatCheckBoxChecked”; and Check: “not isStatCheckBoxChecked”; entries.
Compiling a new installer
To make a new installer, you need to compile it using the edited script file. To do this, open the file in Inno Setup editor (if you used another editor, like me) and click the Compile button in the main toolbar. This command is also located in the Build menu.
Inno Setup Guide
The new installer will be saved inside the Output folder. You can run it with /silent /norestart switches or by double clicking the setup file.
Delete File After Install Inno Setup Tutorial
If you have any doubts, read the Inno Setup Help referenced earlier or post a comment and I will do my best to answer any questions you may have.