I'm thinking the dowload thing would be a bit more complicated...but it is possible. Probably the easiest way would be to use a Custom Action .NET DLL and use the managed System.Net classes to download MDAC from a URL. I used MDAC as a merge module in the InstallShield project, so the script will not contain references to that.
First off, to understand how I installed the .NET Framework, I did not distribute the whole 20MB EXE that MS has available as a download (although you can do that, just modify the Script). Instead, I ran that EXE with the Command Line Params to just extract the MSI & CAB files that were neccessary for the .NET Framework. And YES, the Framework does contain the Windows Installer setup...that's what I wanted to eliminate (since InstallShield does that for you).
Also take note that the Install functions for MSDE and the SQL Client Tolls NEVER really worked! Apparently the "unattended" script files for the Tools setup doesn't work, and for somereason the command line for the MSDE didn't work...but if you placed the EXACT same command lines in a Batch file...it became magically delicious and worked!
Below is the Script for the "Setup.rul" file. Please keep in mind that you cannot create separate ".rul" files in IS7 (without a huge amount of work). So just overwrite your Setup.rul file with this one.
#include "ifx.h"
#include "isrt.h"
prototype BOOL InstallDotNET();
prototype InstallMSDE(BOOL);
prototype InstallSQLTools();
prototype BOOL IsSQLServerInstalled(BYREF STRING, BYREF BOOL);
prototype BOOL IsSQLServerRunning();
prototype STRING FormatNum(number);
prototype STRING FormatBool(BOOL);
BOOL bReboot;
function OnFirstUIBefore()
STRING sSQLType, sResult;
number nResult, nvResult, nvSize, nUser;
STRING szTitle, szMsg, szQuestion, svName, svCompany, szFile;
STRING szLicenseFile;
LIST listStartCopy;
BOOL bCustom, bInstallMSDE, bInstallSQLTools, bIsSQLInstalled, bNeedsUpgrade;
begin
SHELL_OBJECT_FOLDER = @PRODUCT_NAME;
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome(szTitle, szMsg);
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SdFeatureTree:
szTitle = "";
szMsg = "";
nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 1);
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SdAskDestPath:
nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
if (nResult = BACK) goto Dlg_SdFeatureTree;
Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate(STRINGLIST);
nResult = SdStartCopy(szTitle, szMsg, listStartCopy);
ListDestroy(listStartCopy);
if (nResult = BACK) goto Dlg_SdAskDestPath;
Enable(STATUSEX);
if (!InstallDotNET()) then
abort;
endif;
if (bInstallMSDE) then
MessageBox("Attempting to Install MSDE", MB_OK);
bIsSQLInstalled = IsSQLServerInstalled(sSQLType, bNeedsUpgrade);
MessageBox("SQL Installed?: " + FormatBool(bIsSQLInstalled), MB_OK);
MessageBox("SQL Type: " + sSQLType, MB_OK);
MessageBox("Need Upgrade?: " + FormatBool(bNeedsUpgrade), MB_OK);
if (!bIsSQLInstalled) then
MessageBox("Installing MSDE", MB_OK);
InstallMSDE(FALSE);
elseif ((sSQLType = "MSDE") && (bNeedsUpgrade)) then
MessageBox("Upgrading MSDE", MB_OK);
InstallMSDE(TRUE);
elseif ((sSQLType = "Standard") && (bNeedsUpgrade)) then
MessageBox("SQL Server SP3a needs to be Installed!", MB_OK);
endif;
endif;
if (bInstallSQLTools) then
MessageBox("Installing SQL Tools", MB_OK);
InstallSQLTools();
endif;
Enable(STATUSEX);
return 0;
end;
function OnFirstUIAfter()
STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
number bOpt1, bOpt2;
begin
Disable(STATUSEX);
bOpt1 = FALSE;
bOpt2 = FALSE;
szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);
RebootDialog("", "", SYS_BOOTMACHINE);
end;
function BOOL InstallDotNET()
STRING sKey, sValue, sResult;
BOOL bExists, bInstall;
number nResult, nSize, nType;
begin
bInstall = FALSE;
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
sKey = "Software\\Microsoft\\.NETFramework\\policy\\v1.1";
if (RegDBKeyExist(sKey) >= 0) then
return TRUE;
else
bInstall = TRUE;
endif;
if (bInstall) then
MessageBox(SRCDIR + "DotNetFramework\\NetFX_1.1.msi", MB_OK);
if (Is(FILE_EXISTS, SRCDIR + "DotNetFramework\\NetFX_1.1.msi") = 0) then
MessageBox("The Path to the .NET Framework Setup cannot be found.", MB_OK | SEVERE);
return FALSE;
endif;
SdShowMsg("Installing .NET Framework v1.1", TRUE);
nResult = LaunchAppAndWait("MSIEXEC", "/i \"" + SRCDIR + "DotNetFramework\\NetFX_1.1.msi\" /qn REBOOT=ReallySuppress", WAIT);
SdShowMsg("", FALSE);
if (nResult < 0) then
MessageBox("The Installation of the .NET Framework failed.", MB_OK | SEVERE);
return FALSE;
endif;
endif;
return TRUE;
end;
function BOOL IsSQLServerInstalled(sType, bUpgradeNeeded)
STRING sKey, sService, sVersion, sVersionEx, sSPLevel;
number nResult, nType, nSize;
begin
SdShowMsg("Checking for instances of SQL Server 2000", TRUE);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
nType = REGDB_STRING;
nSize = 256;
sType = "";
bUpgradeNeeded = FALSE;
sKey = "Software\\Microsoft\\Microsoft SQL Server";
if (RegDBKeyExist(sKey) < 0) then
MessageBox("SQL Server is not Installed.", MB_OK);
return FALSE;
endif;
sKey = "Software\\Microsoft\\Microsoft SQL Server\\80";
if (RegDBKeyExist(sKey) < 0) then
MessageBox("SQL Server 2000 is not Installed.", MB_OK);
return FALSE;
endif;
sKey = "Software\\Microsoft\\Microsoft SQL Server\\80\\Tools\\ClientSetup\\CurrentVersion";
if (RegDBKeyExist(sKey) >= 0) then
nResult = RegDBGetKeyValueEx(sKey, "CurrentVersion", nType, sVersion, nSize);
nResult = RegDBGetKeyValueEx(sKey, "CSDVersion", nType, sVersionEx, nSize);
if (nResult < 0) then
sType = "Standard";
else
sType = "MSDE";
endif;
endif;
sKey = "Software\\Microsoft\\Microsoft SQL Server\\80\\Tools\\Service Manager";
if (RegDBKeyExist(sKey) >= 0) then
nResult = RegDBGetKeyValueEx(sKey, "Default", nType, sService, nSize);
sKey = "Software\\Microsoft\\MSSQLServer\\" + sService + "\\CurrentVersion";
if (RegDBKeyExist(sKey) >= 0) then
nResult = RegDBGetKeyValueEx(sKey, "CSDVersion", nType, sVersionEx, nSize);
endif;
endif;
if (StrFind(sVersionEx, "384") >= 0) then
sSPLevel = "Service Pack 1";
bUpgradeNeeded = TRUE;
elseif (StrFind(sVersionEx, "543") >= 0) then
sSPLevel = "Service Pack 2";
bUpgradeNeeded = TRUE;
else
sSPLevel = "Service Pack 3";
bUpgradeNeeded = FALSE;
endif;
SprintfBox(MB_OK, "SQL Server Info",
"SQL Server Type: %s\nService Name: %s\nCurrent Version: %s\nVersion CSD: %s\nService Pack: %s",
sType, sService, sVersion, sVersionEx, sSPLevel);
SdShowMsg("", FALSE);
return TRUE;
end;
function BOOL IsSQLServerRunning()
number nResult;
begin
if (Is(FILE_EXISTS, ProgramFilesFolder + "Microsoft SQL Server\\80\\Tools\\Binn\\scm.exe") = 0) then
MessageBox("Cannot find scm.exe!", MB_OK | SEVERE);
return FALSE;
endif;
nResult = LaunchAppAndWait(ProgramFilesFolder + "Microsoft SQL Server\\80\\Tools\\Binn\\scm.exe ", "-s -Action 1 -Service MSSQLServer -SvcStartType 2", WAIT);
SprintfBox(MB_OK,"SQL Server", "SQLServer Running? %d", nResult);
if (nResult = 1) then
return TRUE;
else
return FALSE;
endif;
end;
function InstallMSDE(Upgrade)
STRING sParams;
number nResult;
begin
if (Is(FILE_EXISTS, SRCDIR + "MSDE\\Setup.exe") = 0) then
MessageBox("The MSDE Install cannot be found.", MB_OK | SEVERE);
return 0;
endif;
sParams = "/qn SECURITYMODE=SQL ALLOWXDBCHAINING=0";
if (Upgrade) then
sParams = sParams + " UPGRADE=1";
endif;
SdShowMsg("Installing SQL Server Desktop Engine...", TRUE);
nResult = LaunchAppAndWait(SRCDIR + "MSDE\\Setup.exe", sParams, WAIT);
if (nResult < 0) then
MessageBox("The Installation of the Microsoft Desktop Engine falied.", MB_OK | SEVERE);
endif;
SdShowMsg("", FALSE);
end;
function InstallSQLTools()
STRING sParams;
number nResult;
begin
if (Is(PATH_EXISTS, SRCDIR + "SQLServer") = 0) then
MessageBox("The Directory containing the SQL Server Tools installation cannot be found.", MB_OK);
return 0;
endif;
SdShowMsg("Installing the SQL Server Tools...", TRUE);
sParams = "\"" + SRCDIR + "SQLServer\\SetupTools.iss\"";
sParams = "-s -m -SMS -f1 " + sParams;
nResult = LaunchAppAndWait("\"" + SRCDIR + "SQLServer\\X86\\Setup\\SetupSQL.exe\" ", sParams, WAIT);
if (nResult < 0) then
MessageBox("The Installation of the SQL Server Tools failed.", MB_OK | SEVERE);
endif;
SdShowMsg("",FALSE);
if (Is(PATH_EXISTS, SRCDIR + "SQLServer\\SP3") = 0) then
MessageBox("The Directory containing the SQL Server Tools SP3 installation cannot be found.", MB_OK);
return 0;
endif;
SdShowMsg("Installing the SQL Server Tools SP3...", TRUE);
sParams = "\"" + SRCDIR + "SQLServer\\SetupToolsSP3.iss\"";
sParams = "-s -m -SMS -f1 " + sParams;
nResult = LaunchAppAndWait("\"" + SRCDIR + "SQLServer\\SP3\\X86\\Setup\\SetupSQL.exe\"", sParams, WAIT);
if (nResult < 0) then
MessageBox("The Installation of the SQL Server Tools SP3 failed.", MB_OK | SEVERE);
endif;
SdShowMsg("",FALSE);
return nResult;
end;
function STRING FormatNum(Num)
STRING sValue;
begin
NumToStr(sValue, Num);
return sValue;
end;
function STRING FormatBool(Value)
STRING sValue;
begin
NumToStr(sValue, Value);
return sValue;
end;
|