Archive: How can I dectect if the .NET Framework 2 is installed?


How can I dectect if the .NET Framework 2 is installed?
Hi!

I'm wondering how can I dectect if the .NET Framework 2 is installed.

Please help. Thanks.


Use forum Search and/or browse the NSIS Repository, esp. parts "Functions & Macros" and "Code Examples".
Or JUST SIMPLY RTFM - "Appendix C: Useful Scripts"
Kthx. Bye.


Ok... this is the best:

http://nsis.sourceforge.net/Get_.NET_Version

Thanks for the link!


You can use this:

Function IsDotNETInstalled
Push $0
Push $1
Push $2
Push $3
Push $4

; Check for HKLM\Software\Microsoft\.NETFramework\InstallRoot value
ReadRegStr $4 HKLM "Software\Microsoft\.NETFramework" "InstallRoot"
; remove trailing back slash
Push $4
Exch $EXEDIR
Exch $EXEDIR
Pop $4
; if the root directory doesn't exist .NET is not installed
IfFileExists $4 0 noDotNET

; Loop through all subkeys in HKLM\Software\Microsoft\.NETFramework\Policy, looking for v2.0
StrCpy $0 0
EnumStart:
EnumRegKey $2 HKLM "Software\Microsoft\.NETFramework\Policy" $0
IntOp $0 $0 + 1
StrCmp $2 "v2.0" GotKey
StrCmp $2 "" noDotNet
goto EnumStart
GotKey:

; Now loop through all values in appropriate key, and make sure its actual directory exists
StrCpy $1 0
EnumPolicy:
EnumRegValue $3 HKLM "Software\Microsoft\.NETFramework\Policy\v2.0" $1
IntOp $1 $1 + 1
StrCmp $3 "" noDotNet
IfFileExists "$4\v2.0.$3" GotDir EnumPolicy
GotDir:

; We have now verified that .NET is there
StrCpy $0 "$4\v2.0.$3"
StrCpy $DotNetOk "1"
; MessageBox MB_OK "Found .NET v2.0 at $0"
Goto done

noDotNET:
StrCpy $0 ""
StrCpy $DotNetOk "0"
Goto done

done:
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd