how to detect machine has DOTNET 2.0
how to detect machine has at leas开发者_JS百科t DOTNET 2.0 or newer installed?
registry key preferred.
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
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).
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
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
seems to have a list of all the installed versions.
[EDIT: 2012-04-04] Useful MSDN knowledge base article with some graphics
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.
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.
精彩评论