Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup - How to prevent installation when application is installed already?

Tags:

inno-setup

I've installed my program. But if I try to install it again, it does and the program is replaced.

I saw this question Inno Setup - How to display notifying message while installing if application is already installed on the machine?

Can I create a certain registry entry so I can check it and prevent a new installation? In this question there is some related information: Skip installation in Inno Setup if other program is not installed.

like image 903
Nico Z Avatar asked Feb 09 '17 12:02

Nico Z


People also ask

What is Suppressmsgboxes?

/SUPPRESSMSGBOXES. Instructs Setup to suppress message boxes. Only has an effect when combined with '/SILENT' and '/VERYSILENT'. The default response in situations where there is normally a choice for the user during installation is: •

Can Inno Setup create MSI?

Create MSI with Inno Setup. The MSI Wrapper was produced to create MSI packages from executable files built with Inno Setup. It puts the setup.exe inside an MSI file and runs it with the specified command line switches when the MSI package is installed.

Which of the given command line parameter is used to suppress logging?

To prevent this behavior, you can suppress the log file by specifying /LogFile= (with no filename argument) after Installutil.exe on the command line.

How do I make an inno file executable?

Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.


1 Answers

You do not need to create any registry key. The installer already creates a registry key for the uninstaller. You can just check that. It's the same key, that the answer to question, you refer to, uses. But you do not need to do the check for version. Just check an existence. Also you should check both the HKEY_LOCAL_MACHINE and the HKEY_CURRENT_USER:

#define AppId "myapp"

[Setup]
AppId={#AppId}

[Code]

function InitializeSetup(): Boolean;
begin
  Result := True;
  if RegKeyExists(HKEY_LOCAL_MACHINE,
       'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
     RegKeyExists(HKEY_CURRENT_USER,
       'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') then
  begin
    MsgBox('The application is installed already.', mbInformation, MB_OK);
    Result := False;
  end;
end;

The application is installed already


Or just reuse IsUpgrade function from Can Inno Setup respond differently to a new install and an update?

like image 183
Martin Prikryl Avatar answered Oct 03 '22 12:10

Martin Prikryl