.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> System Process >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Programaticaly determine operating system using C# Code

Posted By:Rajshree       Posted Date: October 28, 2010    Points: 15    Category: System Process    URL: http://www.dotnetspark.com  

Here's how to programmatically determine the Windows OS you are using. With the help of ManagementObjectSearcher class.
 

using System;
using System.Management;

namespace ConsoleApplication1
{
class Program
{
    public static void Main()
    {
        string winos = "Select Name from Win32_OperatingSystem";
        ManagementObjectSearcher mos =
            new ManagementObjectSearcher(winos);           
        foreach (ManagementObject mo in mos.Get())
        {
            Console.WriteLine("OS Name:  {0}", mo["Name"]);
        }
        Console.ReadLine();
    }
}
}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend