Jump to content

Dell Service Tag / Express Service Tag Converter


thephantomlinguist
 Share

Recommended Posts

I discovered AutoIT about a week ago and immediately realized its potential. My first several scripts were auto-installation scripts (isn't that what AutoIT was designed for?). This is my first attempt at a GUI and a standalone script.

Basically, it converts back and forth between Dell Service Tags and Express Service Codes. The most interesting part for me was the base-conversion, but I'll let you decide for yourself.

The original script: dell_convert.au3

Compiled version: dell_convert.zip

Link to comment
Share on other sites

I discovered AutoIT about a week ago and immediately realized its potential. My first several scripts were auto-installation scripts (isn't that what AutoIT was designed for?). This is my first attempt at a GUI and a standalone script.

Basically, it converts back and forth between Dell Service Tags and Express Service Codes. The most interesting part for me was the base-conversion, but I'll let you decide for yourself.

The original script: dell_convert.au3

Compiled version: dell_convert.zip

Unbelieveable documentation! I wish I had found this routine about a week ago. I use Dell ST's all the time and was using dosxpres.exe until recently when someone else did an AutoIT converter for ST2ESC. What my code does is launch from the Active Directory Computers screen, gets the system name from AD, finds the Service Tag for the machine from the system name, converts it to ESC, gets the mac id's and system type and puts it all into the computer's "description" field. Given the time, I'll try to incorporate your code into the script!
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Unbelieveable documentation! I wish I had found this routine about a week ago. I use Dell ST's all the time and was using dosxpres.exe until recently when someone else did an AutoIT converter for ST2ESC. What my code does is launch from the Active Directory Computers screen, gets the system name from AD, finds the Service Tag for the machine from the system name, converts it to ESC, gets the mac id's and system type and puts it all into the computer's "description" field. Given the time, I'll try to incorporate your code into the script!

I would love to see that script when you're done. I deal a lot with Dell (90% of our computers are Dells) and I have been planning to automate more of the process. What you're describing would be incredibly useful. Can't wait to hear more.

In all of the months worth of posts, no one had posted a Express Service Code to Tag Converter and now there are 2 within the last week...

I wasn't aware of archrival's work. I took a look at his/her code and from first glance it looks like we used a couple of different methods for doing the same thing.

I wish I would have seen it, though. Could have saved me a lot of time on the GUI. I spent hours pouring over the documentation trying to get it right.

Link to comment
Share on other sites

  • 2 weeks later...

I would love to see that script when you're done. I deal a lot with Dell (90% of our computers are Dells) and I have been planning to automate more of the process. What you're describing would be incredibly useful. Can't wait to hear more.

I wasn't aware of archrival's work. I took a look at his/her code and from first glance it looks like we used a couple of different methods for doing the same thing.

I wish I would have seen it, though. Could have saved me a lot of time on the GUI. I spent hours pouring over the documentation trying to get it right.

We both could have saved some time if only we looked at this post:

ezzetabi's _Any2Dec

It converts from base 2 through 36, which could have saved us some time...

Link to comment
Share on other sites

I would love to see that script when you're done. I deal a lot with Dell (90% of our computers are Dells)

I took your work, and that of Brian Keene, and started a new #include file for my work called DellFunctions.au3

Here's what (we) have so far:

#include-once
; ------------------------------------------------------------------------------
; AutoIt Version: 3.0 beta 75
; Language:    English
; Description:  Functions that assist with Dell Computer info
; ------------------------------------------------------------------------------

;=============================================================================
; Function Name:   
; Description:   
; Syntax:         _Ceil( $nValue )
; Parameter(s); $nValue  = Number to be evaluated.
; Requirement(s):  External:   = None.
; Return Value(s): On Success: = Returns next integer value above $nValue.
;                 On Failure: = Returns 0.
;                 @ERROR:    = 0 = No error.
;                               1 = $nValue isn't a number.
; Author(s):       Brian Keene <brian_keene@yahoo.com>
; Note(s):       Any value from the integer itself up to the next integer
;                 will be returned as the next integer above it (ex. "25.3"
;                 returns "26").  But due to restrictions on the number of
;                 decimal places the Int() built-in function can handle.  A
;                 number with greater than 14 decimal places (ex.
;                 "25.999999999999999") will be considered the next integer
;                 above the integer part of the value & then 1 will be added
;                 to that (ex. _Ceil("25.999999999999999") returns "27" NOT 26
;                 because there are 15 "9"'s after the decimal point).
; Example(s):
;   Dim $Ans = Number( InputBox( "_Ceil() Test", "Please enter a # to test." ) )
;   MsgBox( 4096, "_Ceil() Test", "Ceil( " & $Ans & " ) = " & _Ceil( $Ans ) )
;=============================================================================


; Generated by AutoIt Scriptomatic
; This will not work on remote machines if any are WinXP-HomeEdition

;THESE ARE TESTED AND REVIEWED:

Func _GetDellServTag($strComputer)
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
;$strComputer = InputBox("Get System Name","Enter target System Name:")
    $Output=""
    $Output = $Output & "Computer: " & $strComputer  & @CRLF
    $Output = $Output & "==========================================" & @CRLF
    if $strComputer <> "localhost" Then
        $objWMIService = ObjGet("winmgmts:"& "{impersonationLevel=impersonate,"& "authenticationLevel=pktPrivacy}!"& "\\" & $strComputer & "\root\CIMV2")
    Else
        $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    EndIf
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) then
        For $objItem In $colItems
            $strBiosCharacteristics = $objItem.BiosCharacteristics(0)
            $Output = $objItem.SerialNumber
    ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
            Return ($Output)
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_BIOS" )
    Endif
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _GetLastUser($strComputer); network name given to machine by SHS
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
;$strComputer = InputBox("Get Last User's Name:","Enter the name of the target system:","localhost")
$Output=""

$var = Ping($strComputer,250)
If $var Then; if $var was not equal to zero --- also possible:  If @error = 0 Then ...
  ; Msgbox(0,"Status","Online, roundtrip was:" & $var)

    $Output = $Output & "Computer: " & $strComputer  & @CRLF
    $Output = $Output & "==========================================" & @CRLF
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NTLogEvent", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
        For $objItem In $colItems
            if StringInStr($objItem.User,"sau-39\") <> 0 then 
                $LastUser = StringTrimLeft($objItem.User,StringInStr($objItem.User,"\")) & " at: " & WMIDateStringToDate($objItem.TimeWritten)
        ; if MsgBox(1,"Last user was: ",$LastUser) = 2 then Exit
                Return($LastUser)
                Exit
            EndIf
        $Output=""
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NTLogEvent" )
    Endif
Else
    Msgbox(0,"Status","An error occured with number: " & @error)
    Exit
EndIf
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _ValidTagFormat($strTAG)
    $result = 0
    If $strTAG <> "" And $strTAG <> "00000" Then
        $strTAG = StringUpper($strTAG)
        $intLength = StringLen($strTAG)
        If $intLength = 5 Or $intLength = 7 Then
            $result = 0
            For $i = 1 To $intLength
                $intCharCode = Asc(StringMid($strTAG, $i, 1))
                If Number($intCharCode) >= 65 And Number($intCharCode) <= 90 Or Number($intCharCode) >= 48 And Number($intCharCode) <= 57 Then
                    $result = 1
                EndIf
            Next
        EndIf
    EndIf
    Return $result
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _Tag2ESC($strTAG)
    If _ValidTagFormat($strTAG) Then
        $intLength = StringLen($strTAG)
        Dim $intESC
        Dim $Digit[$intLength + 1]
        $x = 1
        For $i = $intLength To 1 Step - 1
            $Digit[$x] = StringUpper(StringMid($strTAG, $i, 1))
            $x = $x + 1
        Next
        For $i = 1 To $intLength 
            If Asc($Digit[$i]) <= 57 Then
                $intESC = $intESC + 36 ^ ($i - 1) * Number($Digit[$i])
            Else
                $intESC = $intESC + 36 ^ ($i - 1) * (Asc($Digit[$i]) - 55)
            EndIf
        Next
        Return $intESC
    EndIf
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _ESC2Tag($intESC)
      $intESC = StringReplace($intESC, "-", "")
    $intESC = Number($intESC)
    Dim $strTAG
    If IsNumber($intESC) And $intESC > 0 Then
        If $intESC = 1 Then
            $strTAG = "00001"
        Else
            $sESC = 4
            If $intESC > 60466175 Then
                $sESC = 6
            EndIf
            For $i = $sESC To 0 Step - 1
                $intDigit = Int($intESC / (36 ^ $i))
                If Not IsNumber($intDigit) Then
                    $intDigit = 0
                    $strTAG = String($strTAG) & String($intDigit)
                ElseIf Number($intDigit) < 10 Then
                    $strTAG = String($strTAG) & String($intDigit)
                Else
                    $strTAG = String($strTAG) & (Chr(Number($intDigit) + 55))
                EndIf
                $intESCr = Number($intESC) - Number($intDigit * (36 ^ $i))
                If IsNumber($intESCr) Then
                    $intESC = $intESCr
                EndIf
            Next
        EndIf
    EndIf
    If _ValidTagFormat($strTAG) Then
        Return StringUpper($strTAG)
    Else
        Return ""
    EndIf
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func WMIDateStringToDate($dtmDate)
    Return (StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2) & " on: " & StringMid($dtmDate, 5, 2) & "/" & StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) & " ")
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _GetPCModel($strComputer)
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
;$strComputer = "sys0404"
    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
        For $objItem In $colItems
        $Output = $objItem.Name & @CRLF
    ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
        Return($Output)
        $Output=""
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystemProduct" )
    Endif
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _GetMacIDs($strComputer)
dim $onemac = ""
dim $pingreply[4] = ["Host is offline","Host is unreachable","Bad destination","Unknown error"]   
dim $x = 0, $i = 0
dim $splitIPC[100]
Global $onlyMacs[1]
Dim $cmdOUT = ""
Dim $rawIPC = ""
Dim $newraw = ""
ClipPut("") 
ToolTip("Getting MacID's of target computer: " & $strComputer)
 
;;; Check to see if machine is online
$var = Ping($strComputer,250)
If $var Then; if $var was not equal to zero --- also possible: If @error = 0 Then ...
    runwait(@comspec & ' /c ' & "\\student2\apps$\_bin\utils\psexec.exe \\" & $strComputer & " ipconfig /all" & "| \\student2\apps$\_bin\clipboard","",@SW_HIDE)
    $newraw = ClipGet()
    ; MsgBox(1,"$cmdOUT=",$newraw)
    $splitIPC = StringSplit($newraw,@CRLF)
    ; MsgBox(1,"$splitIPC[0]=",$splitIPC[0])
    While $x < $splitIPC[0]
        if StringInStr($splitIPC[$x],"Phys") <> "0" Then
            $onemac = StringStripCR(StringStripWS(StringLeft(StringTrimLeft($splitIPC[$x],StringInStr($splitIPC[$x],":")),18),8))
            ;MsgBox(1,"onemac=",$onemac)
                if StringInStr($splitIPC[$x-1],"wireless",0) or StringInStr($splitIPC[$x-1],"wlan",0) then $onemac = $onemac & " WLAN"
                if StringInStr($splitIPC[$x-2],"wireless",0) or StringInStr($splitIPC[$x-2],"wlan",0) then $onemac = $onemac & " WLAN"
            ReDim $onlyMacs[$i + 1]
            _ArrayAdd($onlyMacs,$onemac)
    ; _ArrayDisplay($onlyMacs,"Before arrayPOP onlymacs is:")
            $i = $i + 1
        EndIf
        $x = $x + 1
    WEnd
 
;;; Tidy up the results and format them
;ToolTip("Cleaning up the variables and concatenating them")
    _ArraySort($onlyMacs,1)
    _ArrayPop($onlyMacs)
    if $i > 1 and StringInStr($onlyMacs[1],"WLAN") then _ArraySwap($onlyMacs[0],$onlyMacs[1])
;_ArrayDisplay($onlyMacs,"Here are all of the MacIDs:")
    _ArrayInsert($onlyMacs,0,$i)
;_ArrayDisplay($onlyMacs,"Here is the array after the size is inserted at 0:")
    Return $onlyMacs
Else
Msgbox(0,"Status",$pingreply[@error-1])
Exit
EndIf
 
Exit
EndFunc

Some of these functions may only work on my machine due to limitations/idiosyncrasies of the OS, WMI environment, network paths, params, etc. But the basics are there.

Enjoy! and thanks for your effort and for Brian Keene's!

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

This is an interesting thread; one of the first AutoIt scripts I ever wrote was a Dell ESC converter, but mine just wrapped a Javascript script that I stole from the Premier Support site.

A word of warning to those who receive on-site, 3rd-party repair for their Dell PCs as part of the warranty program: if a motherboard gets replaced, be certain that your repair tech re-sets the Service Tag string in the non-volatile memory. They're supposed to do so. If it's not done you won't be able to get anything meaningful with a WMI SerialNumber query, and there are other side effects, e.g. I spent a half-hour trying to find out why I couldn't set the BIOS or system passwords on a laptop, and it was because there was no Dell Tag or asset tag set in non-volatile memory.

Incidentally, I know that I can use ASSET.COM from DOS to set the Dell Tag myself, but the point is that I shouldn't have to.

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...