Get the BIOS Details of Your System in ASP.Net

Introduction

This article explains how to get the BIOS details of your system. Here I will get the information from the Win32_BIOS class.

What Win32_BIOS  is

The Win32_Desktop WMI class represents the attributes of the computer system's Basic Input/Output Services (BIOS) that are installed on a computer.

Design

Create a new ASP.Net Empty website.

Add one page to that website.

Write the following source code:

  1. <head runat="server">  
  2.     <title></title>  
  3.     <style type="text/css">  
  4.         html  
  5.         {  
  6.             font-size: 1.5em;  
  7.             font-family: Calibri;  
  8.             color: Red;  
  9.         }  
  10.     </style>  
  11. </head>  
  12. <body>  
  13.     <form id="form1" runat="server">  
  14.     <div>  
  15.     </div>  
  16.     </form>  
  17. </body>  
  18. </html> 
Next add a reference of "System.Management".

To add the reference use the following procedure.

Go to Solution Explorer, select the project and right-click on that and choose "Add Reference" from the menu.

1.jpg

A window will open; in that choose the ".Net" tab.

2.jpg

It will show a list. In that list, choose "System.Management" and click the "OK" Button.

3.jpg

Now go to code view and write the following code:

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Management;  
  8. public partial class _Default : System.Web.UI.Page  
  9. {  
  10.     protected void Page_Load(object sender, EventArgs e)  
  11.     {  
  12.         SelectQuery Sq = new SelectQuery("Win32_BIOS");  
  13.         ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);  
  14.         ManagementObjectCollection osDetailsCollection = objOSDetails.Get();  
  15.         foreach (ManagementObject mo in osDetailsCollection)  
  16.         {  
  17. Response.Write("Name : " + mo["Name"].ToString() + "<br/>");  
  18.             string[] BIOSVersion = (string[])mo["BIOSVersion"];  
  19.             string s2 = null;  
  20.             foreach (string version in BIOSVersion)  
  21.             {  
  22.                 s2 += version;  
  23.             }  
  24.             Response.Write("BIOSVersion : " + s2 + "<br/>");  
  25.             Response.Write("Caption : " + mo["Caption"].ToString() + "<br/>");  
  26.             Response.Write("Description : " + mo["Description"].ToString() + "<br/>");  
  27.             Response.Write("InstallableLanguages : " + Convert.ToUInt16(mo["InstallableLanguages"]).ToString() + "<br/>");     
  28.             Response.Write("InstallDate : " + Convert.ToDateTime(mo["InstallDate"]).ToString() + "<br/>");  
  29.             Response.Write("Manufacturer : " + mo["Manufacturer"].ToString() + "<br/>");  
  30.             Response.Write("PrimaryBIOS : " + mo["PrimaryBIOS"].ToString() + "<br/>");  
  31.             Response.Write("ReleaseDate : " + mo["ReleaseDate"].ToString() + "<br/>");  
  32.             Response.Write("SerialNumber : " + mo["SerialNumber"].ToString() + "<br/>");  
  33.             Response.Write("SMBIOSBIOSVersion : " + mo["SMBIOSBIOSVersion"].ToString() + "<br/>");  
  34.             Response.Write("SMBIOSMajorVersion : " + mo["SMBIOSMajorVersion"].ToString() + "<br/>");  
  35.             Response.Write("SMBIOSMinorVersion : " + mo["SMBIOSMinorVersion"].ToString() + "<br/>");  
  36.             Response.Write("SMBIOSPresent : " + mo["SMBIOSPresent"].ToString() + "<br/>");  
  37.             Response.Write("SoftwareElementID : " + mo["SoftwareElementID"].ToString() + "<br/>");  
  38.             Response.Write("SoftwareElementState : " + mo["SoftwareElementState"].ToString() + "<br/>");  
  39.             Response.Write("Status : " + mo["Status"].ToString() + "<br/>");  
  40.             Response.Write("TargetOperatingSystem : " + mo["TargetOperatingSystem"].ToString() + "<br/>");  
  41.             Response.Write("Version: " + mo["Version"].ToString() + "<br/>");  
  42.     }  
  43. }   

In the code above I get the information from Win32_BIOS and display that in the page.

SelectQuery

It represents a WQL (WMI Query Language) SELECT data query.

ManagementObjectSearcher

It retrieves a collection of management objects based on a specified query.

This class is one of the more commonly used entry points to retrieving management information.

ManagementObjectCollection

It represents various collections of management objects retrieved using WMI.

Now build your application, it will show the details of your BIOS details of your system in the page.

4.jpeg


Similar Articles