How to Get the "Friendly" Os Version Name

How to get the friendly OS Version Name?

You can use WMI to get the product name ("Microsoft® Windows Server® 2008 Enterprise "):

using System.Management;
var name = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault();
return name != null ? name.ToString() : "Unknown";

Get OS Version / Friendly Name in C#

Add a reference and using statements for System.Management, then:

public static string GetOSFriendlyName()
{
string result = string.Empty;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
foreach (ManagementObject os in searcher.Get())
{
result = os["Caption"].ToString();
break;
}
return result;
}

How to get operating system name

System.OperatingSystem is a type, you couldn't asign it to a variable. What do you want to achieve? Name of running operating system? You could do it with:

Environment.OSVersion.ToString()

How can I get User Friendly version name of Windows like 'Windows 10 Pro' from UWP

Windows Community toolkit has helpers which has a static utility class SystemInformation.

It provides an easy way to access application as well as system information like OperatingSystem,OperatingSystemArchitecture and OperatingSystemVersion among others which can provide the exact information that you need.

Since this toolkit is maintained and updated very well you can be sure of any cases for future releases

How can I get OS Name and Version details in C# on windows mobile 7?

you can try these links

http://msdn.microsoft.com/en-us/library/ff941122%28v=VS.92%29.aspx

http://msdn.microsoft.com/en-us/library/microsoft.phone.info.deviceextendedproperties%28v=VS.92%29.aspx

you can try this

   public MainPage()
{
InitializeComponent();
GetDeviceInfo();
}
public void GetDeviceInfo()
{
long ApplicationMemoryUsage = DeviceStatus.ApplicationCurrentMemoryUsage;
long PeakMemoryUsage = DeviceStatus.ApplicationPeakMemoryUsage;
string FirmwareVersion = DeviceStatus.DeviceFirmwareVersion;
string HardwareVersion = DeviceStatus.DeviceHardwareVersion;
string Manufacturer = DeviceStatus.DeviceManufacturer;
string DeviceName = DeviceStatus.DeviceName;
long TotalMemory = DeviceStatus.DeviceTotalMemory;
string OSVersion = Environment.OSVersion.Version.ToString(); ;
PowerSource powerSource = DeviceStatus.PowerSource;
AddToList("Memory Usage :" + ApplicationMemoryUsage);
AddToList("Peak Memory Usage :" + PeakMemoryUsage);
AddToList("Firmware Version :" + FirmwareVersion);
AddToList("Hardware Version :" + HardwareVersion);
AddToList("Manufacturer :" + Manufacturer);
AddToList("Total Memory :" + TotalMemory);
AddToList("Power Source:" + powerSource.ToString());
AddToList("Operating System: Windows Phone " + OSVersion.ToString());

}
public void AddToList(string Property)
{
lstboxDeviceInfo.Items.Add(Property);
}

take a look at here for more info

C# Get OS Name Windows 8.1

You could find that info in the registry of Windows. For example, if you have installed Windows 8.1 Pro Edition and execute this lines:

 using Microsoft.Win32;     
//...

var windowsName= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "ProductName","");
var version= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "CurrentVersion", "");
var build= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "CurrentBuild", "");

You will get Windows 8.1 Pro, 6.3 and 9600 respectively.

Also you could use the WMI to get the Windows name, check the answer in this post:

public static string GetOSFriendlyName()
{
string result = string.Empty;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
foreach (ManagementObject os in searcher.Get())
{
result = os["Caption"].ToString();
break;
}
return result;
}

How to get the name of OS in which the code is running using C#?

You could get the Operating System 's friendly name by using WMI.

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
String operatingSystem = String.Empty;

foreach (ManagementObject query in searcher.Get())
{
operatingSystem = query["Caption"].ToString();
break;
}

You could use WMI Code Creator, a great tool from Microsoft to generate WMI queries.

Detecting OS Edition

This is a simple way to do it using WMI

using (var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"))
{
var obj = searcher.Get().Cast<ManagementBaseObject>().FirstOrDefault();
string version = obj["Caption"].ToString(); //Microsoft Windows 10 Home
string architecture = obj["OSArchitecture"].ToString(); //64-bit
}

How can I get a future proof user friendly operating system version?

The WMI classes can be used to extract the required data as follows:

Public Function GetFriendlyOSVersion() As String
Dim query As String
query = "SELECT Caption FROM Win32_OperatingSystem"
Dim results As Object
Set results = GetObject("Winmgmts:").ExecQuery(query)
Dim info As Object
For Each info In results
GetFriendlyOSVersion = info.Caption
Next info
End Function


Related Topics



Leave a reply



Submit