Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


March 26, 2008

Getting the Dell Express Service Code

Having this code can shorten your call time with Dell's technical support team
RSS
View this exclusive article with VIP access -- click here to join |
See More Jscript Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

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 r2r@scriptingprovip.com. 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.
. . .


Already a VIP member?
Please log on to view the full article

Why become a VIP member?

VIP-only online access
VIP CD delivered twice a year: offline access to the entire Windows IT Pro article library
Monthly issue of your choice of Windows IT Pro or SQL Server Magazine

Subscribe Now
Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
What You Need to Know About Microsoft's x64 Server Product Plans

What do Longhorn Server, Windows Compute Cluster Server, and Windows Vista have in common? The x64 platform. ...

WinInfo Short Takes: 4th of July Special Edition

An often irreverent look at some of the week's other news, including a shortened work week thanks to the 4th of July, expensive Windows 7 pricing, Bing's modest monthly gains, IE 8 heading to work, Steve Jobs back at Apple, and so much more ...

How can I stop and start services from the command line?

...


Related Articles Calling WMI Methods with JScript

Rem: Retrieving a Computer’s Manufacturing Information

Automated Argument Validation

VBScripting Solutions: Take Advantage of Named Arguments

Related Events Virtualization Management

Configuration Manager SP1 and R2 Overview

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format

Test Drive IT Solutions and Get Free Music Downloads
Solve your toughest IT problems with these free downloads and receive 5 free music downloads!


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home asp.netPRO Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement | Reprints and Licensing