Getting the Dell Express Service Code

Having this code can shorten your call time with Dell's technical support team


Executive Summary:

Many systems administrators know that every Dell computer has a service tag. What they might not know is that this service tag can be converted into an express service code. Having this code when you call Dell's technical support line can shorten the call time. DellSerial.js is a JScript script that you can use to automatically retrieve a computer's service tag and convert it into an express service code. This script also demonstrates the usefulness of JScript's parseInt function and item method.
I recently had a problem with a Dell computer and needed to contact Dell's technical support to get a replacement hard drive. I called Dell's support line and spoke with a tech support representative who transferred me to a different department because the computer in question had an upgraded support contract.

I got my problem resolved after speaking with the second technician, but she mentioned that I could have reduced my call time if I had the computer's express service code. I asked the technician if she knew how to convert a service tag into an express service code. She did not know how, but a bit of Internet research turned up the answer.

Through my research, I discovered that every Dell computer has a service tag consisting of a series of letters and numbers. The service tag is a base 36 number that you can convert to base 10 to get the express service code. (A base 36 number is one that uses 36 distinct values, with 0 through 9 and A through Z being to most common characters for people who use the Roman alphabet.) As usual, I envisioned a script that could simplify my life by automatically making this conversion.

Introducing DellSerial.js
DellSerial.js, which Listing 1 shows, is a JScript script that retrieves a computer's service tag and converts it to an express service code. As the following command-line syntax shows,

DellSerial.js computername | /tag:servicetag

you can specify either a computer name or the /tag parameter followed by a service tag as the command-line argument. If you want the script to retrieve a specific computer's service tag and express service code over the network, you specify the computer name. For the current computer, specify a single dot (.). If the computer isn't accessible over the network, you can use the /tag parameter.

For example, to retrieve the express service code for the computer mktg01, you'd type the command

DellSerial.js mktg01

Figure 1 shows the script's output when you run the script using this command. If the mktg01 computer isn't available over the network, you can specify the service tag directly on the command line, as in

DellSerial.js /tag:CPBZP52

The script's output from this command will be the same as that in Figure 1, except the computer name won't be specified.

How the Script Works
DellSerial.js begins by declaring a global variable containing the script's name. This variable is used by the usage function. Next, it executes the main function as a parameter to the WScript object's Quit method (that is, the main function's exit code will be the script's exit code).

Inside the main function, the script retrieves a reference to the WshArguments object. The WshArguments object contains the WshUnnamed object, which contains a collection of unnamed command-line arguments (arguments that don't start with a slash), and the WshNamed object, which contains a collection of named command-line arguments (arguments that start with a slash). The main function uses both collections to parse the command line. If the Unnamed collection contains at least one member (i.e., its length property is non-zero), the main function uses the first unnamed argument as the computer name. If the Unnamed collection has no members, the main function checks to see if the /tag argument exists. If it exists and contains a parameter, the function uses the argument's parameter as the service tag.

If the script's command line contains the /? parameter or if no command-line arguments were provided, the main function executes the usage function. The usage function displays a usage message and ends the script.

In callout A in Listing 1, the main function checks to see if it should use Windows Management Instrumentation (WMI) to retrieve a service tag from a computer. If a computer name was specified, the main function uses JScript's GetObject function to retrieve a reference to the SWbemServices object on the computer. It wraps this call inside a try...catch...finally statement in case of an error. If an error occurs, the main function outputs an error message and returns with an error value. This error value is returned to the OS via the WScript object's Quit method.

Next, the main function uses the SWbemServices object's InstancesOf method to return the collection of Win32_SystemEnclosure objects on the computer. In JScript, collections are handled by the Enumerator object, so the function uses the new operator to create the Enumerator object. Next, the function uses the item method to access the first object in the collection. Using the object's SerialNumber property, the function retrieves the computer's serial number, which is the service tag. (This retrieval is more convenient in JScript than in VBScript because VBScript's language syntax forces you to use the For Each...Next statement to iterate through a collection, even if the collection contains only one object.) Lastly, the main function adds the computer name to the output string.

The main function is now ready to convert the service tag into an express service code. To do so, it uses JScript's parseInt function and its toString and split methods, as callout B shows. The parseInt function automatically converts strings into base 10 numbers. The parseInt function's first parameter contains the string to be converted (in this case, the service tag). The second parameter specifies the base, or radix, of the string being converted (in this case, 36). The number returned by the parseInt function is passed to the toString method, which converts it to a string. The split method then returns that string as an array. This is another example where JScript solves a problem much more elegantly than VBScript. VBScript doesn't have a built-in function to convert a base 36 number into a base 10 number.

At callout C, the main function uses a for loop to insert hyphens into the array after every third character and appends this to the output string using the join method to convert the array into a string. The function then echoes the results.

If you work with Dell equipment, I hope that DellSerial.js can shorten the time required when you need to work with Dell's technical support. It has for me.

Share Your Scripting Experiences:

Share your scripting discoveries, comments, solutions to problems, and experiences with products. Email your contributions to [email protected]. Please include your full name and phone number. We edit submissions for style, grammar, and length. If we print your submission, you'll get $100.
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.