Alternatively you can use the function I wrote below. This one makes use of LogicLib.nsh. It should work out-of-the-box without having to know the .NET versions value from the Release key in the registry. As it is written right now it only checks for versions between 4.5
–4.7
.
##
# This one requires the use of LogicLib.nsh
# Copy and paste this code somewhere like .OnInit
Function dotNETCheck
!define CheckDOTNET "!insertmacro _CheckDOTNET"
!macro _CheckDOTNET _RESULT _VALUE
Push `${_VALUE}`
Call dotNETCheck
Pop ${_RESULT}
!macroend
Exch $1
Push $0
Push $1
${If} $1 == "4.7"
StrCpy $R1 460798
${ElseIf} $1 == "4.6.2"
StrCpy $R1 394802
${ElseIf} $1 == "4.6.1"
StrCpy $R1 394254
${ElseIf} $1 == "4.6"
StrCpy $R1 393295
${ElseIf} $1 == "4.5.2"
StrCpy $R1 379893
${ElseIf} $1 == "4.5.1"
StrCpy $R1 378675
${ElseIf} $1 == "4.5"
StrCpy $R1 378389
${Else}
Goto dotNET_FALSE
${EndIf}
ReadRegDWORD $R0 HKLM `SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full` `Release`
IfErrors dotNET_FALSE
IntCmp $R0 $R1 dotNET_TRUE dotNET_FALSE
dotNET_TRUE:
StrCpy $0 true
Goto dotNET_END
dotNET_FALSE:
StrCpy $0 false
SetErrors
dotNET_END:
Pop $1
Exch $0
FunctionEnd
##
# USAGE
# ${CheckDOTNET} $0 "Version Number"
##
# $0 Will hold the version number of the installed .NET
# If $0 is empty ($0 == "") then the error flag is set.
${CheckDOTNET} $0 "4.5"
IfErrors 0 +4
MessageBox MB_ICONSTOP|MB_TOPMOST `You must have v4.5 or greater of the .NET Framework installed. Launcher aborting!`
Call Unload
Quit
StrCmpS $0 true 0 -3