2

To check whether SharePoint is installed on a server or not and if so, which version, we could use the Registry Key for 2010

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\InstalledProducts\"

And for 2013 "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\WSS\InstalledProducts\"

Programmatically checking for this key will tell us whether it is installed or not and it's version. Does the same check hold good for SharePoint 2016 also or there is any better or more check to be done? Can anyone please explain?

1

For SharePoint 2016 you can find HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\16.0\WSS\InstalledProducts\

But if you need to get which SharePoint version is installed in your farm programmatically, you can use CSOM as the following

function getSPServerVersion(result) {
    clientContext = SP.ClientContext.get_current();
    clientContext.executeQueryAsync(function(){
           var serverVersion = clientContext.get_serverVersion();
           result(serverVersion);
        }, 
        function(){
           result(null); 
        });
}


SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function(){
    getSPServerVersion(function(serverVersion)
    {
        console.log("SharePoint instance version:" + serverVersion);
    });
});

You can test this code by opening your SharePoint site, Click F12 to open development tools > At console Paste the above code.

enter image description here

In my case, it's SharePoint 2016 because its build version (16.0.4297.1000) start with 16

For more details Check SP.ClientContext.serverVersion

|improve this answer|||||
  • Thanks for the detailed reply. I clearly mentioned that I know to determine whether SP is installed or not using the Registry Keys. I needed to know if there is a better / other way. BTW, for using JSOM, we need to add reference to SP.js, right? This SP.js would reside in a path which itself will depend on different version. – Ven Mar 30 '17 at 5:41
  • Hi @Ven you have asked Does the same check hold good for SharePoint 2016 also ? I said yes with 16 instead of 15 and 14. then you have asked or there is any better or more check to be done? Can anyone please explain? i provide you a method with JSOM , so what's the issue in my answer ? – Mohamed El-Qassas MVP Mar 30 '17 at 8:06
  • Regarding sp.js, if you will use this code within a visual web part. I think no need where I try it as mentioned above in console within SharePoint page. meanwhile, it will require if you add a new aspx / HTML page that not inherited from SP masterPage. – Mohamed El-Qassas MVP Mar 30 '17 at 8:09
  • I m building a utility which has to be agnostic of the version. It first has to detect if SharePoint is installed or not and if yes, which version and then execute the appropriate code. – Ven Mar 30 '17 at 11:39
  • Great job bro, could you tell me what's the missing from the above answer to can help you? What's the language you are using to achieve your utility? I think i have answered it based on your question so please if it helped you don't forget to upvote and set as answer if not helped you tell me how can I help :) I just want to help ? – Mohamed El-Qassas MVP Mar 30 '17 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.