Set Variable DOTNET40_X86 to TRUE
Read Registry Key HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Version into DOTNET40_X86
if Variable DOTNET40_X86 Greater Than (Version) 4.0.30318
  Set Variable DOTNET40_X86 to TRUE
else
  Set Variable DOTNET40_X86 to FALSE
end
if Variable DOTNET40_X86 Equals FALSE
  Get System Setting Windows 7 into DOTNET40_IS7
  Get System Setting Windows Vista into DOTNET40_ISVISTA
  Get System Setting Windows 2003 into DOTNET40_IS2003
  Get System Setting Windows XP into DOTNET40_ISXP
  Get System Setting Service Pack 1 into DOTNET40_SP1
  Get System Setting Service Pack 2 into DOTNET40_SP2
  Get System Setting Service Pack 3 into DOTNET40_SP3
  if Variable DOTNET40_IS7 Equals FALSE
    if Variable DOTNET40_ISVISTA Equals FALSE
      if Variable DOTNET40_IS2003 Equals FALSE
        if Variable DOTNET40_ISXP Equals FALSE
          Comment: .NET 4.0  is not supported on older Windows versions
          MessageBox: $TITLE$ Setup, $TITLE$ requires at least Windows XP or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
          Terminate Installation
        else
          if Variable DOTNET40_SP3 Equals FALSE
            Comment: .NET 4.0  requires Service Pack 3 on Windows XP
            MessageBox: $TITLE$ Setup, $TITLE$ requires at least Service Pack 3 or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
            Terminate Installation
          end
        end
      else
        if Variable DOTNET40_SP2 Equals FALSE
          Comment: .NET 4.0  requires Service Pack 2 on Windows 2003
          MessageBox: $TITLE$ Setup, $TITLE$ requires at least Service Pack 2 or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
          Terminate Installation
        end
      end
    else
      if Variable DOTNET40_SP1 Equals FALSE
        Comment: .NET 4.0  requires Service Pack 1 on Windows Vista
        MessageBox: $TITLE$ Setup, $TITLE$ requires at least Service Pack 1 or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
        Terminate Installation
      end
    end
  end
  Set Variable PREREQ to TRUE
  Set Variable PRELIST to $PRELIST$$NEWLINE$Microsoft .NET Framework 4.0 
end
 
