• How to get operating system Properties using WMI in C#

    Posted on October 24, 2012 by in Dotnet Tips & Tricks, Tips & Tricks

    public static void RetrieveOperatingSystemProps()
    {
        //initialize the select query with command text
        SelectQuery query = new SelectQuery(@"Select * from Win32_OperatingSystem");
    
        //initialize the searcher with the query it is supposed to execute
        using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
        {
            //execute the query
            foreach (ManagementObject process in searcher.Get())
            {
                //print OS properties
                Console.WriteLine("/*********Operating System Information ***************/");
                Console.WriteLine("{0}{1}", "Caption:", process["Caption"]);
                Console.WriteLine("{0}{1}", "ServicePackMajorVersion :", process["ServicePackMajorVersion"]);
                Console.WriteLine("{0}{1}", "ServicePackMinorVersion:", process["ServicePackMinorVersion"]);
                Console.WriteLine("{0}{1}", "InstallDate:", process["InstallDate"]);
                Console.WriteLine("{0}{1}", "Version:", process["Version"]);
    Console.WriteLine("{0}{1}", "FreePhysicalMemory:", process["FreePhysicalMemory"]);
            }
        }
    }
    

    operating system Properties using WMI 2

    List of Properties:

    Data Type Property Name
    string BootDevice
    string BuildNumber
    string BuildType
    string Caption
    string CodeSet
    string CountryCode
    string CreationClassName
    string CSCreationClassName
    string CSDVersion
    string CSName
    sint16 CurrentTimeZone
    boolean DataExecutionPrevention_Available
    boolean DataExecutionPrevention_32BitApplications
    boolean DataExecutionPrevention_Drivers
    uint8 DataExecutionPrevention_SupportPolicy
    boolean Debug
    string Description
    boolean Distributed
    uint32 EncryptionLevel
    uint8 ForegroundApplicationBoost
    uint64 FreePhysicalMemory
    uint64 FreeSpaceInPagingFiles
    uint64 FreeVirtualMemory
    datetime InstallDate
    uint32 LargeSystemCache
    datetime LastBootUpTime
    datetime LocalDateTime
    string Locale
    string Manufacturer
    uint32 MaxNumberOfProcesses
    uint64 MaxProcessMemorySize
    string MUILanguages[]
    string Name
    uint32 NumberOfLicensedUsers
    uint32 NumberOfProcesses
    uint32 NumberOfUsers
    uint32 OperatingSystemSKU
    string Organization
    string OSArchitecture
    uint32 OSLanguage
    uint32 OSProductSuite
    uint16 OSType
    string OtherTypeDescription
    Boolean PAEEnabled
    string PlusProductID
    string PlusVersionNumber
    boolean PortableOperatingSystem
    boolean Primary
    uint32 ProductType
    string RegisteredUser
    string SerialNumber
    uint16 ServicePackMajorVersion
    uint16 ServicePackMinorVersion
    uint64 SizeStoredInPagingFiles
    string Status
    uint32 SuiteMask
    string SystemDevice
    string SystemDirectory
    string SystemDrive
    uint64 TotalSwapSpaceSize
    uint64 TotalVirtualMemorySize
    uint64 TotalVisibleMemorySize
    string Version
    string WindowsDirectory
    Be Sociable, Share!
      Post Tagged with , ,

    Written by

    Software architect with over 10 years of proven experience in designing & developing n-tier and web based software applications, for Finance, Telecommunication, Manufacturing, Internet and other Commercial industries. He believes that success depends on one's ability to integrate multiple technologies to solve a simple as well as complicated problem.

    View all articles by

    Email : [email protected]

    Leave a Reply