cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Guido_Herrling
Level 3

.NET 3.5 SP1 with InstallScript

Hello.

In our company we use the InstallScript (not InstallScript MSI Project) technology for our setups. Now we have to setup a new setup for our next geneneration Software. This software needs .NET 3.5 SP1.
I didn't find any option to check for .NET or better to install .NET. In any other setuptype this can be done by "Redistributables". Is there any way to do it in plain InstallScript Projects ? If not, how different is the paradigm for InstallScript MSI Projects ?

Guido
Labels (1)
0 Kudos
2 Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I believe the Is() function has support for checking installed versions of .NET, and LaunchApplication() can certainly run Microsoft's .NET redistributables. I'm not aware of any pure InstallScript pre-built options for .NET 3.5 SP1 at this time.
0 Kudos
ZygoCorp
Level 6

Here's what we did since InstallShield does not handle checking and installing prerequisites for updates (v1 required .net 2.0, v2 requires .net 3.5); it only handles for new installs. Indenting is probably messed up,,,

and these are functions we found we needed. IS adds the iversion registry entry after OnMoveData(), and if you abort the install here (we called these from OnMoving(), the next execution thinks this version was already installed, when infact it hadn't) DeleteRegistryVersionAfterAbort();


and we wrote a routine to ask if the user wanted this prereq installed:
AskInstallDotNet3_5SP1();


//------------------------------------------------------------------------
// CheckForDotNet3_5SP1
//
// Determine if .NET 3.5 SP1 is installed.
// If it is, do nothing
// If it is NOT, then flag the feature DotNet3.5SP1 for installation
//
// This is only called for Maintenance installations; it seems that IS2010
// handles this correctly for new installs but not update, modify, or repair
// installs
//
// Returns 0 always
//
// Called by: OnMoving()
//---------------------------------------------------------------------------
function CheckForDotNet3_5SP1()
STRING szMessage, szBaseRegInstallKey, szKeyName, szSvcPk;
NUMBER nResult, nType, nSize;
begin
// Set to FALSE just to be sure
nResult = FeatureSelectItem(MEDIA, "DotNet3.5SP1", FALSE);

nResult = WriteLine(glLogFile, "Establishing .Net 3.5 SP1 prerequisite.");
nResult = Is(DOTNETFRAMEWORKINSTALLED, REGDB_KEYPATH_DOTNET_35);
if (nResult = TRUE) then
Sprintf(szMessage, ".NET 3.5 is installed.");
nResult = WriteLine(glLogFile, szMessage);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
//szBaseRegInstallKey = "\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v3.5";
szBaseRegInstallKey = REGDB_KEYPATH_DOTNET_35;
//szKeyName = "SP";
szKeyName = REGDB_VALUENAME_SP;
// Note: DOTNETSERVICEPACKINSTALLED is not applicable to REGDB_KEYPATH_DOTNET_35
nResult = RegDBGetKeyValueEx(szBaseRegInstallKey, szKeyName, nType, szSvcPk, nSize);
if (nResult < 0) then
Sprintf(szMessage, "Unable to read registry entry %s in mpx_CheckForDotNet3_5SP1. Assuming .Net 3.5 SP1 is NOT installed.", szBaseRegInstallKey ^ szKeyName);
nResult = WriteLine(glLogFile, szMessage);
nResult = AskInstallDotNet3_5SP1();
if (nResult = TRUE) then
nResult = FeatureSelectItem(MEDIA, "DotNet3.5SP1", TRUE);
else // FALSE
Sprintf(szMessage, "User selected to NOT install .Net 3.5 SP1. Aborting the installation.");
nResult = WriteLine(glLogFile, szMessage);
DeleteRegistryVersionAfterAbort();
abort;
endif;
else
if (szSvcPk = "1") then
// life is good
Sprintf(szMessage, "SP1 for .NET 3.5 is installed.");
nResult = WriteLine(glLogFile, szMessage);
else
Sprintf(szMessage, "SP1 for .NET 3.5 is NOT installed.");
nResult = WriteLine(glLogFile, szMessage);
nResult = AskInstallDotNet3_5SP1();
if (nResult = TRUE) then
nResult = FeatureSelectItem(MEDIA, "DotNet3.5SP1", TRUE);
else // FALSE
Sprintf(szMessage, "User selected to NOT install .Net 3.5 SP1. Aborting the installation.");
nResult = WriteLine(glLogFile, szMessage);
DeleteRegistryVersionAfterAbort();
abort;
endif;
endif;
endif;
// Return registry root to default; good practice
RegDBSetDefaultRoot(HKEY_CLASSES_ROOT);
elseif (nResult = FALSE) then
Sprintf(szMessage, ".NET 3.5 is NOT installed.");
nResult = WriteLine(glLogFile, szMessage);
nResult = AskInstallDotNet3_5SP1();
if (nResult = TRUE) then
nResult = FeatureSelectItem(MEDIA, "DotNet3.5SP1", TRUE);
else // FALSE
Sprintf(szMessage, "User selected to NOT install .Net 3.5 SP1. Aborting the installation.");
nResult = WriteLine(glLogFile, szMessage);
DeleteRegistryVersionAfterAbort();
abort;
endif;
else
Sprintf(szMessage, "Unable to determine if .NET 3.5 is installed. Assuming .Net 3.5 SP1 is NOT installed.");
nResult = WriteLine(glLogFile, szMessage);
nResult = AskInstallDotNet3_5SP1();
if (nResult = TRUE) then
nResult = FeatureSelectItem(MEDIA, "DotNet3.5SP1", TRUE);
else // FALSE
Sprintf(szMessage, "User selected to NOT install .Net 3.5 SP1. Aborting the installation.");
nResult = WriteLine(glLogFile, szMessage);
DeleteRegistryVersionAfterAbort();
abort;
endif;
endif;
end;

//---------------------------------------------------------------------------
// mpx_InstallDotNet3_5SP1
//
// Actually install .NET 3.5 SP1 if it is not installed.
// This is only required for Maintenance installations; it seems that IS2010
// handles this correctly for new installs but not update, modify, or repair
// installs
//
// Returns 0 always
//
// Called by: OnMoving()
//---------------------------------------------------------------------------
function mpx_InstallDotNet3_5SP1()
STRING szMessage, szExeCmd, szCmdLine, szBaseRegInstallKey, szKeyName;
NUMBER nResult;
begin
if (FeatureIsItemSelected(MEDIA, "DotNet3.5SP1")) then
Sprintf(szMessage, "Installing .Net 3.5 SP1 prerequisite.");
nResult = WriteLine(glLogFile, szMessage);
SdShowMsg(szMessage, TRUE);
// Install .Net 3.5 SP1
szExeCmd = SUPPORTDIR ^ "Helper.exe";
szCmdLine = "/p dotnetfx35.exe /l 1033 /v \"/q /norestart\"";
Sprintf(szMessage, "Calling: %s %s.", szExeCmd, szCmdLine);
nResult = WriteLine(glLogFile, szMessage);
nResult = LaunchAppAndWait(szExeCmd, szCmdLine, LAAW_OPTION_WAIT);
if (nResult < 0) then
SdShowMsg(szMessage, FALSE);
Sprintf(szMessage, "Could not execute %s %s.\nAborting the installation.", szExeCmd, szCmdLine);
nResult = WriteLine(glLogFile, szMessage);
MessageBox(szMessage, SEVERE);
DeleteRegistryVersionAfterAbort();
Cleanup();
abort;
endif;

// Write registry entry that this was actually executed
// Testing for FeatureIsItemSelected seems to always return TRUE in the OnAbort() method
// Therefore, will change test to look for this registry key
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szBaseRegInstallKey = "\\SOFTWARE\\Zygo Corporation\\Install Data\\MPX";
szKeyName = "InstalledDotNet35SP1";
nResult = RegDBSetKeyValueEx(szBaseRegInstallKey, szKeyName, REGDB_STRING, "1", -1);
if (nResult < 0) then
Sprintf(szMessage, "Unable to set registry entry %s in mpx_InstallDotNet3_5SP1().", szBaseRegInstallKey + "\\" + szKeyName);
nResult = WriteLine(glLogFile, szMessage);
//MessageBox(szMessage, INFORMATION);
else
Sprintf(szMessage, "Successfully set registry entry %s in mpx_InstallDotNet3_5SP1().", szBaseRegInstallKey + "\\" + szKeyName);
nResult = WriteLine(glLogFile, szMessage);
//MessageBox(szMessage, INFORMATION);
endif;
RegDBSetDefaultRoot(HKEY_CLASSES_ROOT);
SdShowMsg(szMessage, FALSE);
endif;
end;
0 Kudos