Archive: Checking for DOT NET Framework


Checking for DOT NET Framework


;Check if DOT NET Installed
;This is an extremly simple function for checking for
;the Dot Net Framework.
;It will abort the installation, so I advised to set it
;as one of the very first things to execute.
Function DotNetExists
Push $0
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\.NETFramework" "InstallRoot"
;Here are some IfFileExists statement in which we just 'fall' through.
IfFileExists $0v3.5.* 0 +3
StrCpy $0 "v3.5" #This step is by no means needed. It is here just for
Goto DotNetHere #the ability to 'DetailPrint' before leaving the function.
IfFileExists $0v3.0.* 0 +3
StrCpy $0 "v3.0"
Goto DotNetHere
IfFileExists $0v2.0.* 0 +3
StrCpy $0 "v2.0"
Goto DotNetHere
IfFileExists $0v1.1.4322 DotNetHereButNotVersion 0 #Here I use a build version to look for.
IfFileExists $0v1.0.* DotNetHereButNotVersion DotNetNotHere #We found a version but too old or didn't find anything.

/* A really short version.
IfFileExists $0v3.5.* DotNetHere 0
IfFileExists $0v3.0.* DotNetHere 0
IfFileExists $0v2.0.* DotNetHere 0
IfFileExists $0v1.1.* DotNetHere 0
IfFileExists $0v1.0.* DotNetHere DotNetNotHere
*/


;Depending on what you want to tell the user, the next area can be as large/small as needed.

DotNetHereButNotVersion:
DetailPrint "Found the DOT NET Framework but is"
DetailPrint "to old of a version."
DetailPrint "Please install version 2.0 or higher."
MessageBox MB_OK "Found the DOT NET Framework but is$\nto old of a version.$\nPlease install version 2.0 or higher."
Pop $0
Abort

DotNetNotHere:
DetailPrint "No versions of the DOT NET Framework were found!"
DetailPrint "Please install version 2.0 or higher."
Pop $0
Abort

DotNetHere:
DetailPrint "Found Version: $0 of the Dot NET Framework"
Pop $0
FunctionEnd


Hope this helps.

Or use this with VersionCompare:
System::Call `mscoree::GetCORVersion(w .R0, i ${NSIS_MAX_STRLEN}, *i) ?u`

($R0 = v2.0.50727)

Stu