Uninstalling files not originally installed by INNO setup - inno-setup

I use Inno Setup for my product's installer/uninstaller. My software has auto-update capabilities during which time it may not only change existing binaries but may also add new ones. These are additional product files that are placed into the product's installation directory - not data files.
The Inno Setup uninstaller only knows to uninstall files by name that it originally put there at install time. Since an automatic update doesn't change either the unins000.exe or unins000.dat files that make up the uninstaller, what would be the appropriate way to delete these new product files at uninstall time?

The easiest way I see is to have a batch file in your program dir that deletes all files that were added after the installation and is executed on uninstall:
[UninstallRun]
Filename: cleanup.cmd; WorkingDir: {app}; Flags: shellexec runminimized
UninstallRun commands are executed as the first step of the uninstallation, so this should work fine. If you are bothered by the idea of running a batch script, you can easily create your own cleanup.exe that deletes the files.
When you perform the auto update, you must also update the cleanup file, so that it includes all files that were added with the current update.

Related

Inno Setup: shared files are not being deleted from my install directory

I have created an installer using Inno 5.5.9 and am installing a number of binary files that need to be marked as shared because a second installer could install a second program to the same directory and these files are common across the two programs.
I am marking the files with the flags 'sharedfile uninsnosharedfileprompt' but they are not removed on uninstall even if they are not in use.
In my testing I install the main program and then uninstall it immediately. The uninstall log says it is 'decrementing shared count' for these files but the shared count is not reaching zero. This is a 32bit program installed onto Windows 10.
#define SourceDirectory "..\bin2017\win32"
#define InstallPath "{app}\bin\Win32\"
[Files]
Source: "{#SourceDirectory}\*.dll"; DestDir: "{#InstallPath}"; Flags: ignoreversion sharedfile uninsnosharedfileprompt
What am I missing to make this work correctly? What could be preventing the uninstaller from decrementing the shared count to zero?
If you need any more info or code please let me know (this is my first question on the excellent site).
Thanks in advance.
The path in the original location has most likely some orphan reference.
I believe your code is correct and the installer behaves correctly. It's just a local problem with reference counting.

Path to uninstaller in Inno Setup

During install, the installer creates a backup directory with a timestamp added to make it unique if installer is started multiple times.
During uninstall I need to process some files (not placed by [Files] and [Dir] section) to be restored in the usUninstall or usPostUninstall. These files are placed in sub-directories in the backup directory.
For this, I need my location where the uninstaller is started so I can restore the files.
I found and tried the GetCurrentDir function. But during uninstall the GetCurrentDir function returns the location c:\WINDOWS\system32.
I tested it also during install, but in that case the GetCurrentDir function returns the location where the installer is started.
How to get the proper location from where the uninstall is started?
The {uninstallexe} constant resolves to a path to the uninstaller.
If you combine that with ExtractFilePath, you get a path to the uninstaller folder:
ExtractFilePath(ExpandConstant('{uninstallexe}'))
Though actually, the path will typically be the installation path. So you can use {app} constant directly.
Do not use GetCurrentDir! It returns the current working directory. What does not have to be the path to the installer.
Use {src} constant.

Inno Setup copy OutputBaseFileName in PostCompile section

I want copy OutputBaseFileName to archive after Inno Setup Studio script compiling is finished.
I prepared this script but it doesn't work.
[PostCompile]
Name: CopyFile({#OutputBaseFilename}, '\\Bckserver\Source\'{#OutputBaseFilename});
I will guess that you want to have the compiler copy the generated installer to yet another directory (\\Bckserver\Source).
This works:
Name: "C:\Windows\System32\cmd.exe"; Parameters: "/c copy C:\path\setup.exe \\Bckserver\Source"
I do not think there's better solution, as Inno Setup Studio does not support preprocessor in the PostCompile section, so you cannot refer to OutputBaseFilename or system directory other than by hard-coding them.

How to eliminate spaces for installation while writing Inno setup file?

I am creating an installer for my project where I am facing a issue.
The project is not running as expected if it is installed in the directory which contains spaces e.g: "C:\Program Files (x86)" and it is working fine if it is installed in a directory which doesn't contains spaces e.g: "C:\Python27".
So as per my understanding there is nothing wrong with project side and its all with the .iss code.
So can anyone please tell me how to solve this issue. Since most of the installers are created using Inno setup and they are installed in the program files there will be a way to solve this and which I am not aware of it.
Regards,
Bharathi
The issue is not with the spaces. My application creates a log file to log the data. Since the normal user doesn't have rights to create the file in the program files folder the application is not working... The application should be run as admin to work.
Create a symlink using mklink.
Create something like this in [RUN] section:
Filename: {cmd}; Parameters: "/c MKLINK /D {sd}\ProgramPathNoSpaces ""{pf}\Program Path With Spaces"; Flags: RunHidden;
Run your application inside the ProgramPathNoSpaces, using a shortcut with the "start in" property defined.
Hope this help you, but everyone is right. The problem is in the application, this is only a workaround.

Prevent additional uninstaller uninstall everything

I have an innosetup installer which installs a plugin into the root directory of an application which is also installed with innosetup. After installing my plugin into this dir there are multiple uninst* files:
app/
unins000.exe (the apps uninstaller)
unins000.dat
unins001.exe (another plugin's uninstaller)
unins001.dat
unins002.exe (my plugin's uninstaller)
unins002.dat
Problem is running unins002.exe uninstalls all files in this folder, I need only the files created by my plugin to be uninstalled.
How can I achieve this?
In the [setup] section you need to provide a different (or non-default) AppId value.
When the installer runs and the same the AppId exists for an existing uninstall manifest then Inno will merge them.
Fixed. It was due to a misconfigured UninstallDelete section.

Resources