HOWTO uninstall a program from Inno Setup kit


One of the many challenges in releasing the latest version of Horodruin was that the main edition switched to 64-bits.

This means that we cannot simply install/update the new program over the existing one, mainly because 64 bits programs have a different default system folder (‘Program Files‘) than 32 bits ones (‘Program Files (x86)‘).

The best option here is to uninstall the old one, before installing the new package.

The solution below will detect the outdated program installation and will uninstall it.

The solution

All the needed info is usually stored under the following registry key:


But, in my case, I need to seek a 32 bits installation on 64 bits Windows that are stored under this other registry key:


In these keys are present the installation data per program’s unique name.
So our next step is to determine this unique name.  For Inno Setup assisted programs, it should be “<program_name>_is1“.

When we have all the needed elements we can write down a small piece of code in the [Code] section in our Inno Setup script.

{ remove previous 32-bits installation }
function Uninstall32bitsVersion () : Boolean;
  sUninstall: string;
  ResultCode: Integer;
  Result := True;
  { is it installed? }
  if RegQueryStringValue (HKLM,
      'UninstallString', sUninstall) then
    { notify & confirm the operation }
    if (MsgBox ('Warning: the current 32-bits version of <my_old_program> will be uninstalled!',
        mbInformation, MB_OKCANCEL) <> IDOK) then
      Result := False;
      { uninstall it }
      ShellExec ('', sUninstall, '/SILENT', '', SW_SHOWNORMAL,
          ewWaitUntilTerminated, ResultCode);

{ installation process interface }
function InitializeSetup(): Boolean;
  Result := Uninstall32bitsVersion ();

Using this piece of code above, your setup will detect the old 32 bits program instance, and:

  •  if it is present, it will ask to uninstall it, giving the chance to abort the operation.
  • else it will uninstall it before the new package processing starts.