If there is a real reason why your application should know this, I would recommend checking for the presence of a component that matters on the desktop / server. For example, if the server version comes with a program or library foo , but not in the desktop version, and you would like to use foo and then check for the existence (and / or version) of foo instead of trying to get it out of Server vs Desktop OS.
(Meanwhile, the sw_vers and system_profiler SPSoftwareDataType commands are one possible starting point for checking the OS version.)
Arkku source share