Archive: Determing if .NET Framework is installed


Determing if .NET Framework is installed
Greetings to everyone.
I'm new here and to the NSIS installer (I LOVE it!) so I'm not sure about this, but here it goes..
I found a post on how to determine in .NET Framework is installed. I changed it some and here is what I've got:

---------------------------------
Function .onGUIInit
Call GotDotNet
FunctionEnd

Function GotDotNet
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\.NETFramework\policy\v1.0" "3705"
IfErrors Check2
Goto End

Check2:
ClearErrors
ReadRegStr $1 HKLM "Software\Microsoft\.NETFramework\policy\v1.1" "4322"
IfErrors Error
Goto End

Error:
MessageBox MB_OK|MB_ICONSTOP "Setup could not detect Microsoft .NET Framework on this computer. $\n Please install Microsoft .NET Framework and run setup again."
ABORT

End:
FunctionEnd
------------------------------------

This works just fine :)
But this wont work when the next version of .NET Framework comes out.
So is there a better way to do this check?

Thx!


You can use EnumRegKey to walk through every key in "Software\Microsoft\.NETFramework\policy\". I have also found this news group thread: http://groups.google.com/groups?q=de...ftngp04&rnum=1. I am currently checking with the help of TechKid if it works both on 1.0 and 1.1.


Testing failed. 1.1 creates a different uninstall key :(


Thanks for the reply.

I think I found another way that is even easier and should work with the next versions of .NET.
It looks at the "InstallRoot" instead.
Works great for me. :-)

Function GotDotNet

ClearErrors

ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\.NETFramework" "InstallRoot"
IfErrors Error
Goto End

Error:
MessageBox MB_OK|MB_ICONSTOP "Setup could not detect Microsoft .NET Framework on this computer. $\n Please install Microsoft .NET Framework and run setup again."
ABORT

End:

FunctionEnd


I have wrote a solution for you it checks the Uninstall Registery for Microsoft .NET Framework if it exists then it Display it in a MessageBox. I test with 1.0 1.1 and both installed it works on all those plus it work when it not installed it.

Here is the code


Name ".NET Framework Check"
AllowRootDirInstall true
OutFile "dotnetCheck.exe"
Caption ".NET Framework Check "
ShowInstDetails show

Section
IntOp $0 0 + 0
EnumStart:
EnumRegKey $R1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" $0
IntOp $0 $0 + 1
StrCmp $R1 "" EnumEnd
ReadRegStr $R2 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$R1" "DisplayName"
StrCpy $R2 $R2 "24" "0"
StrCmp $R2 "Microsoft .NET Framework" CheckGUID EnumStart

CheckGUID:
ReadRegStr $R2 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$R1" "DisplayName"
MessageBox MB_OK "$R2 Installed!"
goto EnumStart
EnumEnd:
SectionEnd

I am sorry, but I have my doubts about this specific piece of code. The display name might be localized for localized versions of .NET framework.


What happens if you tun this on e.g. XP Lognhorn or Windows 2003 Server where the .NET Framework is integrated in the OS?
I should think that there would be no uninstallstring...


Balder I have been working on a new version that is a lot better than the old previous on, KiCHik broght up the localization issue. It was looked into I came up with new ideas and ran them by Kichik. He thought it would work so I wrote the code. Hes tested it out we see no problems but I am going to let him work with my code a little bit as he want to make it a function that returns a value or not if .NET is installed.

So look forward to a post from Kichik with the code.

Nathan Purciful


Thank you so much for the help guys, and I'll be looking forward to try the code when it's finished. :)


There it is:

http://nsis.sourceforge.net/archive/...tances=0,44,89


NICE! Thanks! :)