Thursday 14 February 2013

Getting BIOS Information using JavaScript


Getting BIOS Information using JavaScript
Win32_BIOS: The Win32_BIOS WMI class represents the attributes of the computer system’s basic input/output services (BIOS) that are installed on a computer
Name
Data type
Description
BiosCharacteristics
uint16
Array of BIOS characteristics supported by the system as defined by the System Management BIOS Reference Specification
BIOSVersion
string
Array of the complete system BIOS information
BuildNumber
string
Internal identifier for this compilation of this software element
Caption
string
Short description of the object-a one line string
CurrentLanguage
string
Name of the current BIOS language
Description
string
Description of the object
InstallableLanguages
uint16
Number of languages available for installation on this system
InstallDate
datetime
Date and time the object was installed
LanguageEdition
string
Language edition of this software element
Manufacturer
string
Manufacturer of this software element
Name
string
Name used to identify this software element
PrimaryBIOS
boolean
If TRUE, this is the primary BIOS of the computer system
ReleaseDate
datetime
Release date of the Windows BIOS in the Coordinated Universal Time (UTC) format of YYYYMMDDHHMMSS.MMMMMM(+ -)OOO
SerialNumber
string
Assigned serial number of the software element
SMBIOSBIOSVersion
string
BIOS version as reported by SMBIOS
SMBIOSMajorVersion
uint16
Major SMBIOS version number
SMBIOSMinorVersion
uint16
Minor SMBIOS version number
SMBIOSPresent
boolean
If TRUE, the SMBIOS is available on this computer system
SoftwareElementID
string
Identifier for this software element
SoftwareElementState
uint16
State of a software element
Status
string
Current status of the object
TargetOperatingSystem
uint16
Target operating system of the owning software element
Version
string
Version of the BIOS

BiosCharacteristics Properties:
Value
Meaning
0
Reserved
1
Reserved
2
Unknown
3
BIOS Characteristics Not Supported
4
ISA is supported
5
MCA is supported
6
EISA is supported
7
PCI is supported
8
PC Card (PCMCIA) is supported
9
Plug and Play is supported
10
APM is supported
11
BIOS is Upgradable (Flash)
12
BIOS shadowing is allowed
13
VL-VESA is supported
14
ESCD support is available
15
Boot from CS is supported
16
Selectable Boot is supported
17
BIOS ROM is socketed
18
Boot From PC Card (PCMCIA) is supported
19
EDD (Enhanced Disk Drive) Specification is supported
20
Int 13h – Japanese Floppy for NEC 9800 1.2mb (3.5, 1k Bytes/Sector, 360 RPM) is supported
21
Int 13h – Japanese Floppy for Toshiba 1.2mb (3.5, 360 RPM) is supported
22
Int 13h – 5.25/360KB Floppy Services are supported
23
Int 13h – 5.25/1.2 MB Floppy Services are supported
24
Int 13h – 3.5/720KB Floppy Services are supported
25
Int 13h – 3.5/2.88 MB Floppy Services are supported
26
Int 5h, Print Screen Service is supported
27
Int 9h, 8042 Keyboard services are supported
28
Int 14h, Serial Services are supported
29
Int 17h, printer services are supported
30
Int 10h, CGA/Mono Video Services are supported
31
NEC PC-98
32
ACPI is supported
33
USB Legacy is supported
34
AGP is supported
35
I2O boot is supported
36
LS-120 boot is supported
37
ATAPI ZIP Drive boot is supported
38
1394 boot is supported
39
Smart Battery is supported
40:47
Reserved for BIOS vendor
48:63
Reserved for system vendor

SoftwareElementState Properties:
Value
Meaning
0
Deployable
1
Installable
2
Executable
3
Running

Status Properties:
·         OK
·         Error
·         Degraded
·         Unknown
·         Pred Fail
·         Starting
·         Stopping
·         Service
·         Stressed
·         NonRecover
·         No Contact
·         Lost Comm
TargetOperatingSystem Properties:
Value
Meaning
0
Unknown
1
Other
2
MACOS
3
ATTUNIX
4
DGUX
5
DECNT
6
Digital Unix
7
OpenVMS
8
HPUX
9
AIX
10
MVS
11
OS400
12
OS/2
13
JavaVM
14
MSDOS
15
WIN3x
16
WIN95
17
WIN98
18
WINNT
19
WINCE
20
NCR3000
21
NetWare
22
OSF
23
DC/OS
24
Reliant UNIX
25
SCO UnixWare
26
SCO OpenServer
27
Sequent
28
IRIX
29
Solaris
30
SunOS
31
U6000
32
ASERIES
33
TandemNSK
34
TandemNT
35
BS2000
36
LINUX
37
Lynx
38
XENIX
39
VM/ESA
40
Interactive UNIX
41
BSDUNIX
42
FreeBSD
43
NetBSD
44
GNU Hurd
45
OS9
46
MACH Kernel
47
Inferno
48
QNX
49
EPOC
50
IxWorks
51
VxWorks
52
MiNT
53
BeOS
54
HP MPE
55
NextStep
56
PalmPilot
57
Rhapsody
58
Windows 2000
59
Dedicated
60
VSE
61
TPF

Write the following code.
Script.js
var strComputer = ".";
var SWBemlocator = new ActiveXObject("WbemScripting.SWbemLocator");
var objWMIService = SWBemlocator.ConnectServer(strComputer, "/root/CIMV2");
var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS");
var e = new Enumerator(colItems);


function BiosCharacteristics() {
    for (; !e.atEnd(); e.MoveNext()) {
        return GetBiosCharacteristics(e.item().BiosCharacteristics);
    }
}

function BIOSVersion() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().BIOSVersion;
    }
}

function BuildNumber() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().BuildNumber;
    }
}

function Caption() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().Caption;
    }
}

function CurrentLanguage() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().CurrentLanguage;
    }
}

function Description() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().Description;
    }
}

function InstallableLanguages() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().InstallableLanguages;
    }
}

function InstallDate() {
    for (; !e.atEnd(); e.MoveNext()) {
        return ConvertToDateTime(e.item().InstallDate);
    }
}

function LanguageEdition() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().LanguageEdition;
    }
}

function Manufacturer() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().Manufacturer;
    }
}

function Name() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().Name;
    }
}

function PrimaryBIOS() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().PrimaryBIOS;
    }
}

function ReleaseDate() {
    for (; !e.atEnd(); e.MoveNext()) {
        return ConvertToDateTime(e.item().ReleaseDate);
    }
}

function SerialNumber() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().SerialNumber;
    }
}

function SMBIOSBIOSVersion() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().SMBIOSBIOSVersion;
    }
}

function SMBIOSMajorVersion() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().SMBIOSMajorVersion;
    }
}

function SMBIOSMinorVersion() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().SMBIOSMinorVersion;
    }
}

function SMBIOSPresent() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().SMBIOSPresent;
    }
}

function SoftwareElementID() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().SoftwareElementID;
    }
}

function SoftwareElementState() {
    for (; !e.atEnd(); e.MoveNext()) {
        return GetSoftwareElementState(e.item().SoftwareElementState);
    }
}

function Status() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().Status;
    }
}

function TargetOperatingSystem() {
    for (; !e.atEnd(); e.MoveNext()) {
        return GetTargetOperatingSystem(e.item().TargetOperatingSystem);
    }
}

function Version() {
    for (; !e.atEnd(); e.MoveNext()) {
        return e.item().Version;
    }
}

function GetBiosCharacteristics(charac) {
    switch (charac) {
        case 0: return "Reserved";
        case 1: return "Reserved";
        case 2: return "Unknown";
        case 3: return "BIOS Characteristics Not Supported";
        case 4: return "ISA is supported";
        case 5: return "MCA is supported";
        case 6: return "EISA is supported";
        case 7: return "PCI is supported";
        case 8: return "PC Card (PCMCIA) is supported";
        case 9: return "Plug and Play is supported";
        case 10: return "APM is supported";
        case 11: return "BIOS is Upgradable (Flash)";
        case 12: return "BIOS shadowing is allowed";
        case 13: return "VL-VESA is supported";
        case 14: return "ESCD support is available";
        case 15: return "Boot from CS is supported";
        case 16: return "Selectable Boot is supported";
        case 17: return "BIOS ROM is socketed";
        case 18: return "Boot From PC Card (PCMCIA) is supported";
        case 19: return "EDD (Enhanced Disk Drive) Specification is supported";
        case 20: return "Int 13h - Japanese Floppy for NEC 9800 1.2mb (3.5, 1k Bytes/Sector, 360RPM) is supported";
        case 21: return "Int 13h - Japanese Floppy for Toshiba 1.2mb (3.5, 360RPM) is supported";
        case 22: return "Int 13h - 5.25/360KB Floppy Services are supported";
        case 23: return "Int 13h - 5.25/1.2MB Floppy Services are supported";
        case 24: return "Int 13h - 3.5/720KB Floppy Services are supported";
        case 25: return "Int 13h - 3.5/2.88MB Floppy Services are supported";
        case 26: return "Int 5h, Print Screen Service is supported";
        case 27: return "Int 9h, 8042 Keyboard Services are supported";
        case 28: return "Int 14h, Serial Services are supported";
        case 29: return "Int 17h, Printer Services are supported";
        case 30: return "Int 10h, CGA/Mono Video Services are supported";
        case 31: return "NEC PC-98";
        case 32: return "ACPI is supported";
        case 33: return "USB Legacy is supported";
        case 34: return "AGP is supported";
        case 35: return "I2O boot is supported";
        case 36: return "LS-120 boot is supported";
        case 37: return "ATAPI ZIP Drive boot is supported";
        case 38: return "1394 boot is supported";
        case 39: return "Smart Battery is supported";
        case 40: return "Reserved for BIOS vendor";
        case 41: return "Reserved for BIOS vendor";
        case 42: return "Reserved for BIOS vendor";
        case 43: return "Reserved for BIOS vendor";
        case 44: return "Reserved for BIOS vendor";
        case 45: return "Reserved for BIOS vendor";
        case 46: return "Reserved for BIOS vendor";
        case 47: return "Reserved for BIOS vendor";
        case 48: return "Reserved for system vendor";
        case 49: return "Reserved for system vendor";
        case 50: return "Reserved for system vendor";
        case 51: return "Reserved for system vendor";
        case 52: return "Reserved for system vendor";
        case 53: return "Reserved for system vendor";
        case 54: return "Reserved for system vendor";
        case 55: return "Reserved for system vendor";
        case 56: return "Reserved for system vendor";
        case 57: return "Reserved for system vendor";
        case 58: return "Reserved for system vendor";
        case 59: return "Reserved for system vendor";
        case 60: return "Reserved for system vendor";
        case 61: return "Reserved for system vendor";
        case 62: return "Reserved for system vendor";
        case 63: return "Reserved for system vendor";
        default: return "Unknown";
    }
}

function ConvertToDateTime(unconverted) {
    var converted = "";
    if (unconverted != null) {
        var year = parseInt(unconverted.substr(0, 4));
        var month = parseInt(unconverted.substr(4, 2));
        var date = parseInt(unconverted.substr(6, 2));
        var hours = parseInt(unconverted.substr(8, 2));
        var minutes = parseInt(unconverted.substr(10, 2));
        var seconds = parseInt(unconverted.substr(12, 2));
        var meridian = "AM";
        if (hours > 12) {
            hours -= 12;
            meridian = "PM";
        }
        converted = date.toString() + "/" + month.toString() + "/" + year.toString() + " " + hours.toString() + ":" + minutes.toString() + ":" + seconds.toString() + " " + meridian;
    }
    return converted;
}

function GetSoftwareElementState(ses) {
    switch (ses) {
        case 0: return "Deployable";
        case 1: return "Installable";
        case 2: return "Executable";
        case 3: return "Running";
        default: return "Unknown";
    }
}

function GetTargetOperatingSystem(tos) {
    switch (tos) {
        case 0: return "Unknown";
        case 1: return "Other";
        case 2: return "MACOS";
        case 3: return "ATTUNIX";
        case 4: return "DGUX";
        case 5: return "DECNT";
        case 6: return "Digital Unix";
        case 7: return "OpenVMS";
        case 8: return "HPUX";
        case 9: return "AIX";
        case 10: return "MVS";
        case 11: return "OS400";
        case 12: return "OS/2";
        case 13: return "JavaVM";
        case 14: return "MSDOS";
        case 15: return "WIN3x";
        case 16: return "WIN95";
        case 17: return "WIN98";
        case 18: return "WINNT";
        case 19: return "WINCE";
        case 20: return "NCR3000";
        case 21: return "NetWare";
        case 22: return "OSF";
        case 23: return "DC/OS";
        case 24: return "Reliant UNIX";
        case 25: return "SCO UnixWare";
        case 26: return "SCO OpenServer";
        case 27: return "Sequent";
        case 28: return "IRIX";
        case 29: return "Solaris";
        case 30: return "SunOS";
        case 31: return "U6000";
        case 32: return "ASERIES";
        case 33: return "TandemNSK";
        case 34: return "TandemNT";
        case 35: return "BS2000";
        case 36: return "LINUX";
        case 37: return "Lynx";
        case 38: return "XENIX";
        case 39: return "VM/ESA";
        case 40: return "Interactive UNIX";
        case 41: return "BSDUNIX";
        case 42: return "FreeBSD";
        case 43: return "NetBSD";
        case 44: return "GNU Hurd";
        case 45: return "OS9";
        case 46: return "MACH Kernel";
        case 47: return "Inferno";
        case 48: return "QNX";
        case 49: return "EPOC";
        case 50: return "IxWorks";
        case 51: return "VxWorks";
        case 52: return "MiNT";
        case 53: return "BeOS";
        case 54: return "HP MPE";
        case 55: return "NextStep";
        case 56: return "PalmPilot";
        case 57: return "Rhapsody";
        case 58: return "Windows 2000";
        case 59: return "Dedicated";
        case 60: return "VSE";
        case 61: return "TPF";
        default: return "Unknown";
    }
}

Index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>BIOS</title>
        <style type="text/css">
            th
            {
                text-align: left;
            }
        </style>
        <script type="text/javascript" src="Script.js"></script>
        <script type="text/javascript">
            function load() {
                show("biosCharacteristics", BiosCharacteristics());
                show("biosVersion", BIOSVersion());
                show("buildNumber", BuildNumber());
                show("caption", Caption());
                show("currentLanguage", CurrentLanguage());
                show("description", Description());
                show("installableLanguages", InstallableLanguages());
                show("installDate", InstallDate());
                show("languageEdition", LanguageEdition());
                show("manufacturer", Manufacturer());
                show("name", Name());
                show("primaryBIOS", PrimaryBIOS());
                show("releaseDate", ReleaseDate());
                show("serialNumber", SerialNumber());
                show("smBIOSBIOSVersion", SMBIOSBIOSVersion());
                show("smBIOSMajorVersion", SMBIOSMajorVersion());
                show("smBIOSMinorVersion", SMBIOSMinorVersion());
                show("smBIOSPresent", SMBIOSPresent());
                show("softwareElementID", SoftwareElementID());
                show("softwareElementState", SoftwareElementState());
                show("status", Status());
                show("targetOperatingSystem", TargetOperatingSystem());
                show("version", Version());
            }

            function show(id, value) {
                document.getElementById(id).innerHTML = value;
            }
        </script>
    </head>
    <body onload="load()">
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <th>BiosCharacteristics:</th>
                <td id="biosCharacteristics"></td>
            </tr>
            <tr>
                <th>BIOSVersion:</th>
                <td id="biosVersion"></td>
            </tr>
            <tr>
                <th>BuildNumber:</th>
                <td id="buildNumber"></td>
            </tr>
            <tr>
                <th>Caption:</th>
                <td id="caption"></td>
            </tr>
            <tr>
                <th>CurrentLanguage:</th>
                <td id="currentLanguage"></td>
            </tr>
            <tr>
                <th>Description:</th>
                <td id="description"></td>
            </tr>
            <tr>
                <th>InstallableLanguages:</th>
                <td id="installableLanguages"></td>
            </tr>
            <tr>
                <th>InstallDate:</th>
                <td id="installDate"></td>
            </tr>
            <tr>
                <th>LanguageEdition:</th>
                <td id="languageEdition"></td>
            </tr>
            <tr>
                <th>Manufacturer:</th>
                <td id="manufacturer"></td>
            </tr>
            <tr>
                <th>Name:</th>
                <td id="name"></td>
            </tr>
            <tr>
                <th>PrimaryBIOS:</th>
                <td id="primaryBIOS"></td>
            </tr>
            <tr>
                <th>ReleaseDate:</th>
                <td id="releaseDate"></td>
            </tr>
            <tr>
                <th>SerialNumber:</th>
                <td id="serialNumber"></td>
            </tr>
            <tr>
                <th>SMBIOSBIOSVersion:</th>
                <td id="smBIOSBIOSVersion"></td>
            </tr>
            <tr>
                <th>SMBIOSMajorVersion:</th>
                <td id="smBIOSMajorVersion"></td>
            </tr>
            <tr>
                <th>SMBIOSMinorVersion:</th>
                <td id="smBIOSMinorVersion"></td>
            </tr>
            <tr>
                <th>SMBIOSPresent:</th>
                <td id="smBIOSPresent"></td>
            </tr>
            <tr>
                <th>SoftwareElementID:</th>
                <td id="softwareElementID"></td>
            </tr>
            <tr>
                <th>SoftwareElementState:</th>
                <td id="softwareElementState"></td>
            </tr>
            <tr>
                <th>Status:</th>
                <td id="status"></td>
            </tr>
            <tr>
                <th>TargetOperatingSystem:</th>
                <td id="targetOperatingSystem"></td>
            </tr>
            <tr>
                <th>Version:</th>
                <td id="version"></td>
            </tr>
        </table>
    </body>
</html>


1 comment: