HOW TO GET INFORMATION ABOUT MY COMPUTER(NAME,OS VERSION, PATH ETC) IN C#

Anupam Mishra

Total Post:135

Points:949
Posted by  Anupam Mishra
C#  .NET 
C#
 529  View(s)
Ratings:
Rate this:
Hi All,
I want to print all information about my computer i.e.  OSVersion, UserName,Version,DomainName,System Directory, Machine Name and Processor information using C#. Please give me a  solution with example.

thank you
  1. Anupam Mishra

    Post:135

    Points:949
    Re: How to get information about my computer(Name,OS Version, Path etc) in c#

    Here, we are retrieve  all information(As specify above) of my computer using this code:

    try
                {
                    Console.WriteLine("OS Version : " + System.Environment.OSVersion.Platform.ToString());
                    Console.WriteLine("User Name :" + System.Environment.UserName.ToString());
                    Console.WriteLine("Version :" + System.Environment.Version.ToString());
                    Console.WriteLine("Domain Name: " + System.Environment.UserDomainName.ToString());
                    Console.WriteLine("System Directory : " + System.Environment.SystemDirectory.ToString());
                    Console.WriteLine("OS Version :" + System.Environment.OSVersion.ToString());
                    Console.WriteLine("Machine Name: " + System.Environment.MachineName.ToString());
                    Console.WriteLine("Processor Info: " + System.Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER"));
     using (ManagementObjectSearcher win32Proc = new ManagementObjectSearcher("select * from     Win32_Processor"))
                    {
                        foreach (ManagementObject obj in win32Proc.Get())
                        {
                            Console.WriteLine("Processor: " + obj["Name"].ToString() +      obj["Manufacturer"].ToString() +
    obj["Version"].ToString());
                        }
                    }
         Console.WriteLine();  
                }
                catch (ManagementException e)
                {
                    Console.WriteLine(e);
                }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!