a Flo + a Blog = a Flog my ブログ

13Oct/060

Get Dell Service Tag using WMI in C#

I grew tired of having to reboot and enter the BIOS to view the Service Tag or BIOS revision of Dell computers. So, I wrote a small ruby program to do this from within Windows. I thought others might find it useful.

using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace GetServiceTag
{
class Program
{
static void Main(string[] args)
{
string myString = "";
string target = ".";
//Create the type as specified by the WMI docs, max field is 40

ManagementScope scope = new ManagementScope("\\\\" + target + "\\root\\cimv2");
ManagementPath path = new ManagementPath("Win32_Bios");
ObjectGetOptions obj = new ObjectGetOptions(null);
ManagementClass wmi = new ManagementClass(scope, path, obj);
foreach (ManagementObject bios in wmi.GetInstances())
{
myString += bios.Properties["Serialnumber"].Value.ToString().Trim();
myString += " rev:"+bios.Properties["smbiosbiosversion"].Value.ToString().Trim();

}
System.Console.WriteLine("Your Service tag is:"+myString);
}
}
}

Filed under: En, IT, Windows Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.