Home arrow Articles / Tutorials arrow InnoSetup: Check for .Net 3.5
InnoSetup: Check for .Net 3.5 PDF Print E-mail
Written by Marc   
02.06.2008

After some time away from InnoSetup I'm back on that tool again to build some fairly complex Installers. Most of them need to check if .Net Version 3.5 is installed on the workstation the Software is installed. If .Net 3.5 is not yet installed the Installer should show a message box to the user right at the beginning and asking if he wants to download .Net 3.5 right now. If the user clicks "Yes" the Microsoft Download-Page will be shown otherwise the Installed will be canceled.

To do this one need a little InnoScript (Pascal) and a custom message so it can be translated easily. Add the following code to your InnoSetup script to do this:

[CustomMessages]
dotnetmissing=This application needs Microsoft .Net Version 3.5. Do you like to download and install it now?

 
[CustomMessages]
dotnetmissing=This application needs Microsoft .Net 3.5 which is not yet installed. Do you like to download it now?
[Code]
function InitializeSetup(): Boolean;
var
    ErrorCode: Integer;
    netFrameWorkInstalled : Boolean;
    isInstalled: Cardinal;
begin
  result := true;
 
    // Check for the .Net 3.5 framework
  isInstalled := 0;
  netFrameworkInstalled := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5', 'Install', isInstalled);
  if ((netFrameworkInstalled)  and (isInstalled <> 1)) then netFrameworkInstalled := false;
 
  if netFrameworkInstalled = false then
  begin
    if (MsgBox(ExpandConstant('{cm:dotnetmissing}'),
        mbConfirmation, MB_YESNO) = idYes) then
    begin
      ShellExec('open',
      'http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&DisplayLang=en',
      '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
    end;
    result := false;
  end;
 
end;
 

More advanced will be the integration of download and install it right within the Installer itself. This topic will be covered later on. Contact me, if you need this.

 
Next >
Joomla Template design by RocketTheme