Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Service Tag from Dell Machine using .net?

Tags:

c#

vb.net

wmi

I've got a class that pulls model information (hardware info) for a local machine code is like so:

   Imports System.Management

Public Class clsWMI
    Private objOS As ManagementObjectSearcher
    Private objCS As ManagementObjectSearcher
    Private objMgmt As ManagementObject
    Private m_strComputerName As String
    Private m_strManufacturer As String
    Private m_StrModel As String
    Private m_strOSName As String
    Private m_strOSVersion As String
    Private m_strSystemType As String
    Private m_strTPM As String
    Private m_strWindowsDir As String


    Public Sub New()

        objOS = New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
        objCS = New ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
        For Each objMgmt In objOS.Get


            m_strOSName = objMgmt("name").ToString()
            m_strOSVersion = objMgmt("version").ToString()
            m_strComputerName = objMgmt("csname").ToString()
            m_strWindowsDir = objMgmt("windowsdirectory").ToString()
        Next

        For Each objMgmt In objCS.Get
            m_strManufacturer = objMgmt("manufacturer").ToString()
            m_StrModel = objMgmt("model").ToString()
            m_strSystemType = objMgmt("systemtype").ToString
            m_strTPM = objMgmt("totalphysicalmemory").ToString()
        Next
    End Sub

    Public ReadOnly Property ComputerName()
        Get
            ComputerName = m_strComputerName
        End Get

    End Property
    Public ReadOnly Property Manufacturer()
        Get
            Manufacturer = m_strManufacturer
        End Get

    End Property
    Public ReadOnly Property Model()
        Get
            Model = m_StrModel
        End Get

    End Property
    Public ReadOnly Property OsName()
        Get
            OsName = m_strOSName
        End Get

    End Property

    Public ReadOnly Property OSVersion()
        Get
            OSVersion = m_strOSVersion
        End Get

    End Property
    Public ReadOnly Property SystemType()
        Get
            SystemType = m_strSystemType
        End Get

    End Property
    Public ReadOnly Property TotalPhysicalMemory()
        Get
            TotalPhysicalMemory = m_strTPM
        End Get

    End Property

    Public ReadOnly Property WindowsDirectory()
        Get
            WindowsDirectory = m_strWindowsDir
        End Get

    End Property

End Class

Any possibility to get a service tag from WMI ? From the client side form I display values like so:

   Dim objWMI As New clsWMI()
        With objWMI
            Debug.WriteLine("Computer Name = " & .ComputerName)
            Me.Label1.Text = "Name: " & .ComputerName
            Debug.WriteLine("Computer Manufacturer = " & .Manufacturer)
            Me.Label2.Text = "Manufacturer: " & .Manufacturer
            Debug.WriteLine("Computer Model = " & .Model)
            Me.Label3.Text = "Model: " & .Model
            Debug.WriteLine("OS Name = " & .OsName)
            Me.Label4.Text = "OS Name: " & .OsName
            Debug.WriteLine("OS Version = " & .OSVersion)
            Me.Label5.Text = "OS VERSION: " & .OSVersion

            Debug.WriteLine("System Type = " & .SystemType)
            Me.Label6.Text = "System type = " & .SystemType

            Debug.WriteLine("Total Physical Memory = " & .TotalPhysicalMemory)
            Me.Label7.Text = "Memory: " & .TotalPhysicalMemory
            Debug.WriteLine("Windows Directory = " & .WindowsDirectory)
            Me.Label8.Text = "Win Directory: " & .WindowsDirectory
        End With
like image 979
JonH Avatar asked Oct 08 '09 13:10

JonH


People also ask

How do I get a Dell service tag?

Entering the Service Tag in the BIOS setup programPress F2 when the Dell logo is displayed to enter the BIOS setup program. Navigate to the Main tab and enter the Service Tag in the Service Tag Input field.


3 Answers

I think you need to get the serial number from the BIOS like this:

Select SerialNumber From Win32_BIOS

On Dell's I believe this corresponds to the service tag

like image 64
Jason Miesionczek Avatar answered Oct 23 '22 16:10

Jason Miesionczek


Here is some C# code that should get it

Here im getting from Win32_ComputerSystem but if you desire you can easly convert it to run againt Win32_Bios

void GetComputerSystem()
{
        // http://msdn.microsoft.com/en-us/library/aa394102(VS.85).aspx
        ManagementObjectCollection oReturnCollection;
        try
        {
            ObjectQuery query = new ObjectQuery("Select UserName,Name,Manufacturer,Model from Win32_ComputerSystem");
            ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(gManager, query);
            oReturnCollection = oSearcher.Get();
            oSearcher.Dispose();
        }
        catch
        {
            gHasError = true;
            return;
        }

        //loop through found drives and write out info
        foreach (ManagementObject oReturn in oReturnCollection)
        {
        // Disk name  
            object oLoggedInUser = oReturn["UserName"];
            if (oLoggedInUser == null)
                gOSInfo.UserName = "None";
            else
                gOSInfo.UserName = (string)oLoggedInUser;

            string Manufacturer = (string)oReturn["Manufacturer"];
            string Model = (string)oReturn["Model"];
        }
    }
}
like image 43
EKS Avatar answered Oct 23 '22 15:10

EKS


I wrote a program the recovers the Dell Service Tag, Express Code and links to the Driver and Warranty information. You can find the C# code at

http://samuelhaddad.com/software-projects/dellservicetagfinder/

I hope this helps others.

like image 39
Sam Plus Plus Avatar answered Oct 23 '22 14:10

Sam Plus Plus