How to get the "friendly" OS Version Name?

I am looking for an elegant way to get the OS version like: "Windows XP Professional Service Pack 1" or "Windows Server 2008 Standard Edition" etc.

Is there an elegant way of doing that?

I am also interested in the processor architecture (like x86 or x64).

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";

IRS deposits coronavirus stimulus $1,200 checks: Work out your , How much money you could get. How to update the IRS with your banking information. What to do if you're usually exempt from filing taxes or receive federal  Here's how to get Windows 10 for free, if you're currently running a licensed and activated copy of Windows 7, Windows 8 or Windows 8.1 Home or Pro: 1. Go to the Download Windows 10 website. 2.

You should really try to avoid WMI for local use. It is very convenient but you pay dearly for it in terms of performance. This is quick and simple:

    public string HKLM_GetString(string path, string key)
    {
        try
        {
            RegistryKey rk = Registry.LocalMachine.OpenSubKey(path);
            if (rk == null) return "";
            return (string)rk.GetValue(key);
        }
        catch { return ""; }
    }

    public string FriendlyName()
    {
        string ProductName = HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName");
        string CSDVersion = HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CSDVersion");
        if (ProductName != "")
        {
            return (ProductName.StartsWith("Microsoft") ? "" : "Microsoft ") + ProductName +
                        (CSDVersion != "" ? " " + CSDVersion : "");
        }
        return "";
    }

IRS stimulus check: Can you get one and how to find the payment , The IRS is still sending $1200 stimulus payments via the mail and direct deposit. See if you meet the requirements and when you can expect to receive your  LATEST NEWS: ABC Announces 2020 Return Date for "How to Get Away With Murder" Visit the ABC Shop for How to Get Away with Murder clothing and merchandise. Stream your favorite Disney, Pixar, Marvel, Star Wars, and Nat Geo movies and TV shows on Disney+.

Why not use Environment.OSVersion? It will also tell you what operating this is - Windows, Mac OS X, Unix, etc. To find out if you are running in 64bit or 32bit, use IntPtr.Size - this will return 4 bytes for 32bit and 8 bytes for 64bit.

Economic Impact Payments, We don't have your direct deposit information and; We haven't scheduled your payment yet. Get My Payment. EIP laptop  First and foremost, you should always be aiming to get recipe books from Timmy and Tommy, as you can get a bunch of recipes that are useful in various kinds of decorations.

Try:

new ComputerInfo().OSVersion;

Output:

Microsoft Windows 10 Enterprise

Note: Add reference to Microsoft.VisualBasic.Devices;

How to Use the Tools on IRS.gov to Get Your Economic Impact , What can the Get My Payment tool do for me? IF you are required to file a federal income tax return for 2019 or 2018, … and you  A new gen 8 mythical Pokemon named Zarude was announced on February 27, 2020. At the time of writing, no information has been announced regarding how to get Zarude other than the fact that Zarude

Sample output:

Name = Windows Vista
Edition = Home Premium
Service Pack = Service Pack 1
Version = 6.0.6001.65536
Bits = 64

Sample class:

class Program
{
    static void Main( string[] args )
    {
        Console.WriteLine( "Operation System Information" );
        Console.WriteLine( "----------------------------" );
        Console.WriteLine( "Name = {0}", OSInfo.Name );
        Console.WriteLine( "Edition = {0}", OSInfo.Edition );
        Console.WriteLine( "Service Pack = {0}", OSInfo.ServicePack );
        Console.WriteLine( "Version = {0}", OSInfo.VersionString );
        Console.WriteLine( "Bits = {0}", OSInfo.Bits );
        Console.ReadLine();
    }
}

Source code for OSInfo class: http://www.csharp411.com/determine-windows-version-and-edition-with-c/ However there is an error in the code, you will need to replace the "case 6" statement (it's just before #endregion NAME) with this:

case 6:
    switch (minorVersion)
    {
        case 0:

            switch (productType)
            {
                case 1:
                    name = "Windows Vista";
                    break;
                case 3:
                    name = "Windows Server 2008";
                    break;
            }
            break;
        case 1:
            switch (productType)
            {
                case 1:
                    name = "Windows 7";
                    break;
                case 3:
                    name = "Windows Server 2008 R2";
                    break;
            }
            break;
    }
    break;

And if you want to go a step further and see if your program is running in 64 or 32 bit:

public static class Wow
{
    public static bool Is64BitProcess
    {
        get { return IntPtr.Size == 8; }
    }

    public static bool Is64BitOperatingSystem
    {
        get
        {
            // Clearly if this is a 64-bit process we must be on a 64-bit OS.
            if (Is64BitProcess)
                return true;
            // Ok, so we are a 32-bit process, but is the OS 64-bit?
            // If we are running under Wow64 than the OS is 64-bit.
            bool isWow64;
            return ModuleContainsFunction("kernel32.dll", "IsWow64Process") && IsWow64Process(GetCurrentProcess(), out isWow64) && isWow64;
        }
    }

    static bool ModuleContainsFunction(string moduleName, string methodName)
    {
        IntPtr hModule = GetModuleHandle(moduleName);
        if (hModule != IntPtr.Zero)
            return GetProcAddress(hModule, methodName) != IntPtr.Zero;
        return false;
    }

    [DllImport("kernel32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    extern static bool IsWow64Process(IntPtr hProcess, [MarshalAs(UnmanagedType.Bool)] out bool isWow64);
    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    extern static IntPtr GetCurrentProcess();
    [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
    extern static IntPtr GetModuleHandle(string moduleName);
    [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
    extern static IntPtr GetProcAddress(IntPtr hModule, string methodName);
}

'Kimmy vs. the Reverend' endings: How to get the best one in the , The 'Unbreakable Kimmy Schmidt's new Netflix interactive special, 'Kimmy vs. The Reverend,' only has two real endings. Here's how to get the  Starting these quests will take you to Nazjatar. Once there, you’ll need to complete the intro quest in order to unlock a portal between this near area and each affiliation’s hub world. The portal that leads Alliance players to and from Nazjatar opens up between Mezzamere and Boralus. The portal

Golden Tools: How to Unlock Golden Axe, Shovel, Watering Can , How to Craft Golden Axe. Once you have unlocked the Golden Axe crafting recipe, it can be crafted using the following materials at any workbench: 1 Gold Nugget  Midday, especially during summer, is the best time to get sunlight. At noon, the sun is at its highest point, and its UVB rays are most intense. That means you need less time in the sun to make sufficient vitamin D (5). Many studies also show that the body is most efficient at making vitamin D at noon (6, 7).

GTA Online Lucky Wheel glitch: How to win the Casino Podium Car , Keep spinning until you get the prize you want, including the Casino Podium Car or Lost Slamvan, with this GTA Online Lucky Wheel glitch. Unless you learn how to get rid of them, they can destroy your well-maintained lawn. Moles aren't the only troublesome garden pests. Voles can devour your flower bulbs, munch on the roots of your carrots, potatoes and other root vegetables, damage your trees and shrubs, eat your grass and leave well-worn paths through your yard.

How to get a stimulus check during the coronavirus crisis, Americans whose adjusted gross income was less than $75,000 will receive the maximum amount: $1,200. Reduced payments are sent to single  wikiHow is where trusted research and expert knowledge come together. Since 2005, wikiHow has helped billions of people to learn how to solve problems large and small. We work with credentialed experts, a team of trained researchers, and a devoted community to create the most reliable, comprehensive and delightful how-to content on the Internet.

Comments
  • Be careful, I've seen lots of code samples for this that breaks when the user is not an admin... and of course lots of code samples that works for a non-admin user as well. Just be wary ^^
  • Use FirstOrDefault instead of First method or this line will fail with exception due to invocation of First of empty collection.
  • Using Cast<T> instead of OfType<T> also yields slightly better performance.
  • Some of my users are getting an UnauthorizedAccessException exception when my software runs exactly the above code. Any idea why that might be?
  • If it's as simple as this, why are people suffering so much?
  • It is this simple to get the "friendly" name of the local machine's OS. It can gets more complicated when OS version numbers are involved, which was not what was asked.
  • @NateS that's not suffering. this is suffering!
  • Note: This only works, as written, on the local computer. You have to change Registry.LocalMachine.OpenSubKey(path) to Registry.OpenRemoteBaseKey(RegistryHive.LocalMachine, computer).OpenSubKey(path); to make it a true WMI replacement (which is usually used for connecting to remote computers), and pass in the computer. You would also need to check if the Remote Registry service is running using ServiceController sc = new ServiceController("RemoteRegistry", computer); if (sc.Status.Equals(ServiceControllerStatus.Running)) { ... // do your stuff } & can start it if not: sc.Start();
  • Environment.OSVersion does give you the human version of hte OS name. For example, where WMI will give you Microsoft Windows 8.1 Pro, Environment.OSVersion gives Microsoft Windows NT 6.2.9200.0.
  • I found Environment.OSVersion to be inappropriate unless you have an app.manafest file that states supported OSes. Otherwise you might get the entirely wrong OS version if your app is running as Windows Vista instead of Windows 10, for example.
  • IntPtr.Size will return 4 if you're compiling .NET apps for an x86 platform, even if running on a 64bit OS. Better solution is here: stackoverflow.com/questions/336633/…