What is the most reliable way to determine which version of SharePoint is installed. Whether it is WSS or MOSS. If MOSS, whether it is standard or enterprise.
I want to programmatically detect the exact SharePoint version installed..
PS: I already have posted this question at SharePoint.SE but could not find a convincing answer.
You could try to use
SPFarm.Local.BuildVersion
orSPWebService.ContentService.Farm.BuildVersion
(from this previous question) and to build a lookup table based on this: How to find the level of SharePoint you are running?Another option is to read directly from
ConfigDB
database, onVersions
table; you can find more information here.As suggested there, the probably most reliable method is to check for the availability of a feature. There is no function in the SharePoint API that can tell you if it's WSS, MOSS Standard, or MOSS Enterprise.
Registry keys on server
You can look for these within the registry key HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\InstalledProducts.
Programmatically
See the article How To: Detect the Installed SKU of SharePoint 2010 on MSDN. It has a list of GUIDs for each SKU:
PowerShell
You can also use the PowerShell command get-spfarm | select Products to output GUIDs for the installed SKUs.