Home > DeveloperSection > Forums > How to get information about my computer(Name,OS Version, Path etc) in c#
Anupam Mishra

Total Post:135

Points:949
Posted on    January-27-2016 7:08 AM

 C# C#  .NET 
Ratings:


 1 Reply(s)
 273  View(s)
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


Anupam Mishra

Total Post:135

Points:949
Posted on    January-27-2016 7:15 AM

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);
            }


Don't want to miss updates? Please click the below button!

Follow MindStick