Is there any way to get the OS name the user is currently using?
3 Answers
You can use
System.Environment
class
Environment.OSVersion.ToString()
See Environment.OSVersion Property
Gets an OperatingSystem object that contains the current platform identifier and version number.

- 184,426
- 49
- 232
- 263
-
yeah!!! I'm aware of tat property. but how do i get the name of the OS..?? There is an API - win32_operatingsystem which gives me the OS name. But tat requires WMI service in runnin/stopped mode. Gettin error if the service is in paused state. So help me out wit a method to get the name of the OS if any. – Hanny Mar 15 '10 at 08:02
-
Sadly, this was removed in `.NET Standard 1.6`. – Jesse Chisholm Mar 22 '17 at 20:32
You can use the Environment.OSVersion property.
Version version = Environment.OSVersion;
To decode the version, refer to the wikipedia page of Microsoft Windows Timeline. For example, if the version is 6.1.7600, then it is either a Windows 7 or a Windows Server 2008 R2.
Note that there is no direct API to get the OS name, because a same version can refer to multiple public OS names.

- 27,111
- 5
- 56
- 81
You cannot retrieve the OS name directly. Instead use the Environment.OSVersion.ToString(
) property to interpret the version & display the OS Name.
This article has a sample that will help you. It covers Win95 to Win7.
All you need to do is write a function that will return the OS name as shown in the above article.

- 15,234
- 19
- 61
- 78