0

I'm created a setup for a .NET project. The intention is to automatically build in other MSI's and required packages so that it can scan the system and then automatically install the correct packages as required.

What I have so far:

[Files]
; Ensure all the prerequisites are installed
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\mysql-connector-net-6.8.3.msi"; Check: needsMySQLNET; DestDir: "{tmp}"; DestName: "mysqlNET.msi"; Flags: solidbreak
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\mysql-connector-odbc-5.3.2-win32.msi"; Check: needsMySQLODBC; DestDir: "{tmp}"; DestName: "mysqlODBC.msi"; Flags: solidbreak
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\sharepointclientcomponents_x64.msi"; Check: (IsWin64 and needsSharePtClient); DestDir: "{tmp}"; DestName: "sharept.msi"; Flags: solidbreak
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\sharepointclientcomponents_x86.msi"; Check: ((not IsWin64) and needsSharePtClient); DestDir: "{tmp}"; DestName: "sharept.msi"; Flags: solidbreak
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\NDP451-KB2858728-x86-x64-AllOS-ENU.exe"; Check: needsFramework; DestDir: "{tmp}"; DestName: "NDP451.exe"; Flags: ignoreversion

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\mysqlNET.msi"""; 
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\mysqlODBC.msi""";
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\sharept.msi"""; 
Filename: "{tmp}\NDP451.exe"; Parameters: "/q:a /c:""install /l /q"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: Installing .NET Framework if needed. This may take several minutes.

[Code]
//--------------------------------------------------------------------------------
// .NET helpers
//--------------------------------------------------------------------------------
function isDotNet451Detected(): Boolean;
var 
  success: Boolean;
  release: Cardinal;
begin
  success := RegQueryDWordValue(HKLM, 
                        'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\', 
                        'Release', 
                        release);
//For .net versions
//http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx#net_b 
  Result := success and (release = 378758);
end;

function needsFramework(): Boolean;
begin
  Result := (isDotNet451Detected = False);
end;
//--------------------------------------------------------------------------------
// MySQL .NET connector 6.8.3
//--------------------------------------------------------------------------------
function isMySQLNETconnectorInstalled(): Boolean;
var 
  success: Boolean;
  version: String;
begin
  success := RegQueryStringValue(HKLM, 
                        'SOFTWARE\Wow6432Node\MySQL AB\MySQL Connector/Net\', 
                        'Version', 
                        version); 
  Result := success and (CompareStr(version, '6.8.3') = 0);
end;

function needsMySQLNET(): Boolean;
begin
  Result := (isMySQLNETconnectorInstalled = False);
end;
//--------------------------------------------------------------------------------
// MySQL ODBC Connector 5.3
//--------------------------------------------------------------------------------
function isMySQLODBCconnectorInstalled(): Boolean;
var
  success: Boolean;
  version: String;
begin
  success := RegQueryStringValue(HKLM, 
                        'SOFTWARE\MySQL AB\MySQL Connector/ODBC 5.3\', 
                        'Version', 
                        version); 
  Result := success and (CompareStr(version, '5.3.2') = 0);
end;

function needsMySQLODBC(): boolean;
begin
  Result := (isMySQLODBCconnectorInstalled = False);
end;
//--------------------------------------------------------------------------------
// Sharepoint client components
//--------------------------------------------------------------------------------
function isSharepointClientInstalled(): Boolean;
begin
  Result := RegKeyExists(HKLM, 'SOFTWARE\Microsoft\SharePoint Client Components');
end;

function needsSharePtClient(): Boolean;
begin
  Result := (not isSharepointClientInstalled);
end;

The checks in 'Files' section work well, however the 'Run' section tries to install the files which are specified in the 'Parameters' option and these aren't present so I get an error message.

My question is, is there a way to detect if the file specified in 'Parameters' exists before attempting to install?

I've tried BeforeInstall but not sure how to use it as it doesn't seem to accept a return.

Thank you,

1
  • Solved! I added /quiet to the MSI command line parameters.
    – SPlatten
    Oct 7, 2014 at 13:26

1 Answer 1

1

First off, I would recommend you moving your prerequisites installation into the PrepareToInstall event. That's the proper place for installing prerequisites.


To answer your question, no, there is no way to detect if the file specified in the Parameters param exists before entry processing as well as you cannot get that parameter value in script. But if you'll stay by the way you are installing your prerequisites, you can still do (at least) the following:

  • reuse your existing Check functions also for your [Run] section entries
  • write for your [Run] section entries Check functions for instance just with the FileExists function (however that would require to copy/paste those file names from your Parameters params)
  • use the AfterInstall functions to immediately run the just processed [Files] entry (which would change the time when the installer would be executed)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.