4

I am using Inno Setup to create a BootStrapper for My .NET developed project.

While using PascalScript, I am facing some problems. But before that, here is the Script I am using to create the BootStrapper

#define MyAppName "<ProductName>"
#define MyAppVersion "<ProductVersion>"
#define MyAppPublisher "<Company Name>"
#define MyAppURL "<URL>"
#define MyAppExeName "<AppName>.exe"
#define MyAppCopyright "Copyright@2015"
#define MyContact "<Contact No>"

[Setup]
AppId={{69A884D3-671F-4DFB-9E23-F6FA35BD6264}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=<License File Path>
OutputDir=<Output Directory Path>
OutputBaseFilename=<Output File Name>
Compression=lzma
SolidCompression=yes
SetupIconFile=<Icon File Path>
ArchitecturesInstallIn64BitMode=x64
AppCopyright={#MyAppCopyright}
AppContact={#MyContact}
VersionInfoVersion=1.5
VersionInfoCompany=<Company Name>
VersionInfoProductName=<Product Name>
VersionInfoProductVersion=<Product Version>

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "<Path>\NDP452-KB2901907-x86-x64-AllOS-ENU.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall; Permissions: admins-full; Check: Framework45IsNotInstalled
Source: "<Path>\CRRuntime_32bit_13_0_13.msi"; DestDir: "{tmp}"; Flags: deleteafterinstall 32bit; Permissions: admins-full;
Source: "<Path>\CRRuntime_64bit_13_0_14.msi"; DestDir: "{tmp}"; Flags: 64bit deleteafterinstall; Permissions: admins-full; Check: IsWin64
Source: "<Path>\SSCERuntime_x86-ENU.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall 32bit; Permissions: admins-full
Source: "<Path>\SSCERuntime_x64-ENU.exe"; DestDir: "{tmp}"; Flags: 64bit deleteafterinstall; Permissions: admins-full; Check: IsWin64

Source: "<Path>\<Product>.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "<Path>\File1.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Run]
Filename: {tmp}\NDP452-KB2901907-x86-x64-AllOS-ENU.exe; Parameters: "/q /norestart"; Check: Framework45IsNotInstalled; StatusMsg: Microsoft Framework 4.0 is being installed. This process might take some time. Please wait.....

Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\CRRuntime_32bit_13_0_13.msi"; StatusMsg: Crystal Reports Runtime is being installed. Please wait....;

Filename: {tmp}\SSCERuntime_x86-ENU.exe; StatusMsg: Microsoft SQL Compact 4.0 is being installed. Please wait.....

[Code]
function Framework45IsNotInstalled(): Boolean;
var
  regresult: Cardinal;
begin
  RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Install', regresult);
  if (regresult = 0) then 
  begin
    Result := True;
  end
  else
  begin
  Result := False;
  end;
end;

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

Now I have three problems regarding this issue :

  1. How to check if the system architecture is 32Bit or 64Bit and execute the respective file accordingly ?

e.g. As mentioned in the script, I have attached Two files for Crystal Reports, Now while executing setup, setup should detect the System Architecture and Run the respective file. I tried to solve this using This Link here on StackOverdlow but didn't quite understand it.

  1. Check if the Prerequisite is already installed on System or not

e.g. To check if the .NET Framework already installed on machine, I got the script mentioned above and its working fine. How to do that for Crystal Report or SQL Compact ?

I tried this Script for Crystal Report but it's not working.

[Code]
function CheckForCrystalReports: Boolean;
var
  regresul: Cardinal;
begin
  RegQueryDWordValue(HKLM, 'SOFTWARE\SAP BusinessObjects\Suite XI 4.0\Installer\CRV','Install',regresul);
  if(regresul = 0) then
  begin
  Result := True;
  end 
  else
  begin
  Result := False;
  end; 
end;
  1. Run executable in Silent Mode

e.g. In above script, I am using Parameters: "/q /norestart"; to run the setup in Silent mode and its working. But how to do that for *.msi file ? I tried some parameters but they are not working.

Community
  • 1
  • 1
Mahadev
  • 856
  • 1
  • 17
  • 44
  • You cannot ask three distinct questions in a single post. – Martin Prikryl Sep 30 '15 at 12:22
  • 1
    Anyway for the first question, see [Inno-setup 32bit and 64bit in one](http://stackoverflow.com/q/4833831/850848). – Martin Prikryl Sep 30 '15 at 12:22
  • 1
    [msi command line switches](https://technet.microsoft.com/en-us/library/cc759262%28v=ws.10%29.aspx) and [msdn source](https://msdn.microsoft.com/en-us/library/aa367988%28v=vs.85%29.aspx) – RobeN Sep 30 '15 at 14:43
  • @MartinPrikryl : Sorry for Big question and Thanks for the link. It worked. – Mahadev Oct 01 '15 at 03:32
  • @RobeN : Thanks for the link. I tried that already but the parameter `/q` or `/qn` isn't working. While execution, it prompts error message as `Parameters not supported`. – Mahadev Oct 01 '15 at 03:34
  • @Mahadev is this installer available on network? If yes, I could check if it supports parameters. – RobeN Oct 01 '15 at 08:40
  • @RobeN : No but `CRRuntime_32bit_13_0_13.msi` can be downloaded to check the parameters to use with. – Mahadev Oct 01 '15 at 08:49
  • I have tried `msiexec /passive /i "C:\CRRuntimeTest\CRRuntime_32bit_13_0_13.msi"` and it worked as intended. Show us you `Code` as probably there is kind of problem. Exaple `[Run] Filename: "{tmp}\CRRuntime_32bit_13_0_13.msi"; Parameters: "/passive"; Flags: shellexec waituntilterminated skipifdoesntexist; StatusMsg: "Installing CRRuntime..."` – RobeN Oct 01 '15 at 09:24
  • @RobeN : Here is the Code from above question. `[Run]` `Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\CRRuntime_32bit_13_0_13.msi"; StatusMsg: Crystal Reports Runtime is being installed. Please wait....; ` May be I just don't know how to use it in above context and I tried `/passive` but is isn't working in above line – Mahadev Oct 01 '15 at 10:12

1 Answers1

1

Try this solution with ShellExec:

[Run] 
Filename: "{tmp}\CRRuntime_32bit_13_0_13.msi"; Parameters: "/passive";
 Flags: shellexec waituntilterminated skipifdoesntexist;
 StatusMsg: "Crystal Reports Runtime is being installed. Please wait..."; 

If you want to call via MSIEXEC:

[Run] 
Filename: "msiexec.exe"; Parameters: "/passive /i ""{tmp}\CRRuntime_32bit_13_0_13.msi"""; 
 Flags: waituntilterminated skipifdoesntexist; 
 StatusMsg: "Crystal Reports Runtime is being installed. Please wait...";

P.S. In your code snippet from Comment there were quotations missing for Parameters. You should Open and Close Parameters with " then if you need to use quotation in the parameters line you have to use it Doubled. ""


For SQL Compact you may use following code:

[Files]
Source: "C:\Temp\SSCERuntime_x64-ENU.exe"; DestDir: "{tmp}"; 
 Flags: nocompression deleteafterinstall uninsremovereadonly  
Source: "C:\Temp\SSCERuntime_x86-ENU.exe"; DestDir: "{tmp}"; 
 Flags: nocompression deleteafterinstall uninsremovereadonly  

[Run] 
Filename: "{tmp}\SSCERuntime_x64-ENU.exe"; Parameters: "/qn /i";  
 Flags: waituntilterminated skipifdoesntexist; 
 StatusMsg: SQL Compact 4.0 x64 is being installed. Please wait...; 
 Check: (IsWin64) and (not IsSQLCompact40Installed); 
Filename: "{tmp}\SSCERuntime_x86-ENU.exe"; Parameters: "/qn /i";  
 Flags: waituntilterminated skipifdoesntexist; 
 StatusMsg: SQL Compact 4.0 x86 is being installed. Please wait...; 
 Check: (not IsWin64) and (not IsSQLCompact40Installed); 

[Code]
function IsSQLCompact40Installed(): Boolean;
var
  InstallDirString : String;
begin
  result := false;
  if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v4.0',
   'InstallDir', InstallDirString) then begin
    if FileExists(InstallDirString + '\sqlcecompact40.dll') then
       result := true;
  end;
end;
RobeN
  • 5,346
  • 1
  • 33
  • 50
  • Thanks. It worked like a charm. Can you help me with my other mentioned problems ? – Mahadev Oct 01 '15 at 12:09
  • I have a Question No. 2 still pending. :) – Mahadev Oct 01 '15 at 12:09
  • Export and attach registry branch for `HKLM` `\SOFTWARE\SAP BusinessObjects`. You would also have to specify which version of SQL Compact you want to check - 3.5, 4.0? x86, x64? – RobeN Oct 01 '15 at 13:45
  • @Mahadev I have updated the answer with sample check for SQL Compact – RobeN Oct 01 '15 at 19:16
  • @RobenN : Thank you very much but I have already solved it for SQL Compact. But thank you for `IsSQLCompact40Installed()`. If possible, just let me know any similar registry entry for crystal report. – Mahadev Oct 02 '15 at 03:14
  • @Mahadev For `CRRuntime_32bit_13_0_13.msi` you can use: `RegQueryStringValue(HKLM, 'SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Enterprise\InstallRoot', 'Path', CristalPath)` and there you can check if specific `FileExists` in `win32_x86` subfolder. – RobeN Oct 02 '15 at 07:14
  • @RobenN : Thanks. That'll definitely help. :) – Mahadev Oct 02 '15 at 09:14