Search code examples
inno-setup

Inno Setup: Check if OpenDCL is installed, otherwise install it


I want that my script checks, if OpenDCL is installed. If it isn't, it should install it.

This is the code:

Source:

[Setup]
AppId={{7EED6191-0CC5-4D95-B28B-D5AB92F09685}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName=C:\Cobiax\{#MyAppName}
DisableDirPage=yes
UsePreviousAppDir=yes
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultGroupName={#MyAppName}
InfoAfterFile=C:\Cobiax\Sorgenti\Cobiax Plan\info.txt
OutputBaseFilename=CobiaxPlan v1.0      
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin                                    

[UninstallDelete]
Type: filesandordirs; Name: "C:\Cobiax\"

[Files]
Source: C:\Cobiax\Sorgenti\OpenDCL.Runtime.8.0.1.0.msi; \
    DestDir: C:\Cobiax\Cobiax Plan\; Flags: deleteafterinstall

[Run]
Filename: msiexec.exe; Parameters: /i {app}\OpenDCL.Runtime.8.0.1.0.msi

[UninstallRun]
Filename: msiexec.exe; Parameters: /x {app}\OpenDCL.Runtime.8.0.1.0.msi

[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

Thank you very much, Dennis

Ps. Is it possible to hide that splash screen?

windows installer


Solution

    1. You have different paths to OpenDCL.Runtime.8.0.1.0.msi in [Files] and [Run] section. You install the package to a fixed path C:\Cobiax\Cobiax Plan, while you run it from a user-defined installation path {app}. As the file is temporary, you probably want to install and run it from {tmp}.

    2. In any case, both paths probably contain a space (Cobiax Plan or Program Files). So you run

      msiexec.exe /i C:\Program Files\MyAppName\OpenDCL.Runtime.8.0.1.0.msi
      

      That's wrong. That's why you get the msiexec usage screen.

      If the path contains a space, it needs to be enclosed to quotes:

      msiexec.exe /i "C:\Program Files\MyAppName\OpenDCL.Runtime.8.0.1.0.msi"
      

    The correct code would be:

    [Files]
    Source: C:\Cobiax\Sorgenti\OpenDCL.Runtime.8.0.1.0.msi; DestDir: {tmp}; \
        Flags: deleteafterinstall
    
    [Run]
    Filename: msiexec.exe; Parameters: "/i ""{tmp}\OpenDCL.Runtime.8.0.1.0.msi"""