PDA

View Full Version : How to Detect and Download .Net Framework


Sorn
12-04-2008, 10:05 AM
In spite of the few .Net Dependancies Examples on this board they all required .Net Framework to be included with the installer, bloating the size outlandishly. Take for example .Net Framework 3.5 Redistribution is 198Mb so to include this with a installation was out of the question for me so I created these functions to handle detecting if .Net Framework 3.5 was installed and if not Download it and install.

Enjoy, comments and suggestions are welcome!


function CheckReg()
myVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Net Framework Setup\\NDP\\v3.5","Version", true); -- Detects .Net Framework Version 3.5

if (myVar == "") then
--Framework not found
Dialog.Message(".Net Framework Version",".Net Framework Version 3.5 was not found, Setup will now try and download and install it!", MB_OK);
GetFramework();
else
--Framework found!
UpdateNextButton(); -- CHANGE THIS TO MATCH YOUR SCREEN BUTTONS
end
end

function GetFramework()
local Framework_Installed
-- Check to see if the user is connected to the internet
connected = HTTP.TestConnection("http://www.indigorose.com", 20, 80, nil, nil);
-- If they are connected.
if connected then
--If not found then download framework
URL = "http://download.microsoft.com/download/6/0/f/60fc5854-3cb8-4892-b6db-bd4f42510f28/dotnetfx35.exe"; -- URL for .Net Framework 3.5 Redist (198Mb)
-- Download a file to their temporary directory.
StatusDlg.Show(MB_ICONNONE, false);
HTTP.Download(URL, SessionVar.Expand("%TempFolder%\\dotnetfx35.exe"), MODE_BINARY, 20, 80, nil, nil, nil);
-- Get any error codes that may have been returned by the download action.
error = Application.GetLastError();
StatusDlg.Hide();
-- If there was an error during the download, display the error message.
if error ~= 0 then
result = Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
-- If there was no error during the download.
else
-- Run the exectuable that was downloaded.
File.Run(SessionVar.Expand("%TempFolder%\\dotnetfx35.exe", "", "", SW_SHOWNORMAL, true));
end
else
Dialog.Message("Internet Connection Error", "Setup could not detect a internet connection, please connect and try again!")
end

MatthiasRoschk
01-01-2009, 11:38 AM
Hello,

i'm very new in Setup Factory and have problems to detect the Framework.
Wow is your script exactly to use ?
The Problem is where have i to add your script and what about the UpdateNextButton(); funktion ?

Please can i have a exactly example ?


Thanks and a happy new year all !!
Matthias

Bothwell
09-09-2009, 08:38 AM
Has the script posted by Scorn been verified by an IndioRose member?

Ulrich
09-22-2009, 11:47 PM
I have derived a new detection module from the original .NET 3.5 SP1 framework dependency module that ships with Setup Factory. My version will use the bootstrapper (2.82 MB) instead of the full installer (almost 200 MB). If the .NET framework is not detected, it will start the bootstrapper, which, using some progress dialogs, will download and install the required files for the computer where it is run. After the framework was deployed, your installer will continue.

You find the installer here (http://www.mindquake.com.br/suf-net35sp1.php).

Ulrich