Showing posts with label OS Version and Service Pack Info. Show all posts
Showing posts with label OS Version and Service Pack Info. Show all posts

Wednesday, May 4, 2011

Find Client PC Operating System and It's Service Pack

These days I am working on a project and today (04.05.2011) I came up with some sort of a small modification to the application by letting the user to see the current OS and It's Service Pack in their application. So I wrote the following piece of code and thought of sharing it with my techi friends :)


Note : Please add reference to System.Management


using System;
using System.Management;

namespace RetrieveSystemInfo
{


class Program
{


static void Main(string[] args)
{

 ManagementObjectSearcher searcher2 = new
 ManagementObjectSearcher("select * from Win32_OperatingSystem");


 foreach (ManagementObject objMgmt in searcher2.Get())
 {
  string sss = objMgmt["name"].ToString();
  string [] aa = sss.Split(new char [] {'|'});
  string bb = aa[0].ToString();

 OperatingSystem OS = Environment.OSVersion;
 string ServicePackDetails = OS.ServicePack;

 Console.WriteLine("OS Version is : " + bb);
 Console.WriteLine("Service Pack is : " + ServicePackDetails);

}

}
}
}