Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install .Net 3.5 on Windows 8 with Inno Setup

I've been using Inno Setup to check for and install the .NET 2.0 framework for one of my applications. It's worked pretty faultessly by checking for a Registry Key and simply downloading the .NET installer and installing prior to installing my application.

From what I understand this isn't working in Windows 8. Windows 8 bundles .NET 2.0 in the .NET 3.5 package which is enabled via the W8 "Install Windows Features" applet thingamy. Rather than downloading the .NET 2.0 installer I'd rather have Inno trigger the installation of the Windows feature applet to enable .NET 3.5 support. Any ideas how this could be done?

like image 817
nemmy Avatar asked Dec 27 '22 01:12

nemmy


2 Answers

According to Microsoft, trying to run the redistributable should automatically trigger internal activation of the feature on Windows 8. So if you're bundling the dotnetfx35 redistributable with your installer then you should not need to change anything.

However if you're downloading the redistributable on demand then it is more efficient to detect Windows 8 or later and trigger the install via the following command line:

Dism /online /enable-feature /featurename:NetFx3 /All

In Inno, you should do this via Exec from within the PrepareToInstall event function.

like image 189
Miral Avatar answered Jan 04 '23 14:01

Miral


SOLUTION

Thanks for @Miral for the suggestion.

Added an additional check to determine if Windows 8 was running:

GetWindowsVersionEx(Version);
if (Version.Major=6) and (Version.Minor=2) then
  begin
    Windows8:=true;
  end;

Then included this code in the NextButtonClick event and checking if the CurPage is wpReady:

 if dotNetNeeded and Windows8 then
    begin
      Exec('Dism', ' /online /enable-feature /featurename:NetFx3 /All /NoRestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
    end;
like image 24
nemmy Avatar answered Jan 04 '23 13:01

nemmy