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
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