tags:

views:

76

answers:

6

how to detect machine has at least DOTNET 2.0 or newer installed?

registry key preferred.

+1  A: 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727

Or for other versions example:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v3.0
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319
Svisstack
does this exist if there is 3.5 or 4.0
Tom
@Tom: yes, i added example
Svisstack
+1  A: 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP seems to have a list of all the installed versions?

noonand
+3  A: 

I would probably follow these instructions as they are from MS

http://support.microsoft.com/kb/315291

As mentioned in other answers this question seems like a good resource for finding our via the Registry. However, by looking at the OP comments, the easiest way would be to add a launch condition to your Setup & Deployment Package requesting the .NET Framework Version 2 or higher must be installed.

http://msdn.microsoft.com/en-us/library/xxyh2e6a.aspx

Barry
That article dates from 2007, and while it may work there are some better (more established / more widely used and consequently better documented) ways of checking nowadays.
slugster
A: 

As far as I know there is no registry key installed on the system by .NET that specifies "Hey, I am installed". However, you could simply check to see if the v2.0.50727 Registry Key exists, or you could check to see if the .NET folder exist on disk at "C:\Windows\Microsoft.NET\Framework\v2.0.50727".

Edit:

As 'slugster' pointed out, apparently .NET does install a registry value called 'Install' under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727" with a DWORD value of '1' if the framework is installed. The rest follow the same pattern except for version .NET 4.0, which places this registry value under the registry subkey named 'Full' or 'Client', which I am assuming one is for the Client Profile and the other is self-explanatory.

David Anderson
Checking for the existence of a folder is no guarantee that the framework is installed. Also the framework install status **does** get entered in the registry.
slugster
+1  A: 

This has been well covered before here on SO, this previous answer should be everything you need - worked for me when i used it (and it is well voted for, which is a measure of how reliable it is).

slugster
well this gets a list of all versions, I want to detect during setupper if my CODE works, meaning if there is NET 2.0 or newer installed.
Tom
@Tom, so like i mentioned above, you don't have to check them all, just pick the one you want (although some of them do have to be checked in combination for an accurate answer - 3.5 also requires 3.0 and 2.0 to be installed).
slugster
A: 

I noticed its best to check if this Reg key exists:

Software\Microsoft.NETFramework\policy\v2.0

If its not there I will install DOTNET.

Tom