I need to know if my program is running on a windows Server or a users desktop. I have tried Environment.OSVersion
but the issue there is that Windows 8 and Windows Server 2012 share a version and build number.
Asked
Active
Viewed 243 times
0

Jinjubei
- 338
- 3
- 12
-
2Research first...http://stackoverflow.com/questions/577634/how-to-get-the-friendly-os-version-name – Rick S Jun 16 '16 at 14:30
-
3What *aspects* of their "server-ness" or "desktop-ness" do you actually need to distinguish between? – Damien_The_Unbeliever Jun 16 '16 at 14:30
-
I use a server edition of Windows as my desktop machine. Now what? – Jeroen Mostert Jun 16 '16 at 14:55
-
@RickS Thanks, I did research first or I wouldn't have asked the question. Damien_The_Unbeliever just if the version of windows was server or not RickS gave the answer I needed. – Jinjubei Jun 16 '16 at 14:57
-
So what are you going to do with Rick/Sean's answer? Are you going to *parse* the returned string, looking for the word "server"? That's an exceptionally fragile solution, and not a good idea. The only thing you should be doing with the string returned by the WMI call is displaying it somewhere in the UI. Which is rather pointless, the user knows what OS version they're running, or they don't care. If you gave us more information (like by answering Damien's question), we could give you an *appropriate* solution. – Cody Gray - on strike Jun 16 '16 at 14:59
-
@CodyGray, I thought I had answered Damien's question. We have a start up program and it just needs to know if it is running on windows Server(we currently use 4 versions) or windows 8,8.1,10(desktop versions). – Jinjubei Jun 16 '16 at 15:01
-
So what do you do about people like me and Jeroen who run server versions as their desktop OS? Your app is just broken? Or it load the wrong thing? Oops. – Cody Gray - on strike Jun 16 '16 at 15:03
-
@CodyGray The program runs in a controlled office environment. The variable of users with windows server on their desktop does not exist. – Jinjubei Jun 16 '16 at 15:04
-
You are still placing yourself at the mercy of Microsoft's marketing department. It is anyone's guess what they'll name the server version of Windows 10. The correct solution would be to call `VerifyVersionInfo` and test that the product type is either `VER_NT_SERVER` or `VER_NT_DOMAIN_CONTROLLER` (i.e., not `VER_NT_WORKSTATION`). You shouldn't be so quick to jump on a half-assed solution. Doing it the right way doesn't even require you to use WMI, which will be about 10,000 times slower. – Cody Gray - on strike Jun 16 '16 at 15:14