Batch File: How to retrieve Asset Tag / Serial Number for a Dell computer

This guide is a quickie on how you can use a batch file to retrieve asset tag and / or serial number information for a Dell desktop or laptop.  This recipe assumes that the Dell computer has had its asset tag entered into the BIOS. Note, not all computer motherboards use this field in WMIC but Dell computers will.


Basic batch file skills will help you understand this process.

1. Create a new text file and rename it with a .bat extension (ie create a getasset.txt and rename to getasset.bat)

2. Right-click on the bat file we created (ie getasset.bat) and choose Edit.  This will open up notepad.

3. Enter in the following pieces of code:
@echo on

for /F "skip=2 tokens=2 delims=," %%A in ('wmic systemenclosure get serialnumber /FORMAT:csv') do (set "serial=%%A")

echo %serial%
pause

4. Explanation of the batch file and for statement:

First, we are turning echo on to see what our batch will do. We using the WMIC command to access the asset tag information on the computer. Not all computers have an asset tag field or use it but Dell computers all do since most are used in an enterprise / corporate environment and are used to keep track of hardware.  We use CSV as our output format so we can parse the data w/our FOR and tokens statement.

We then are setting the asset tag information as a variable called: serial and then use the echo command to just display the information on screen.

I finish with the Pause command so that the batch file / command line window will not disappear after it runs.

POSSIBLE USES:

  • -Create a batch file similar to above and have it output the data we set as the serial variable to a text file and then have another process copy all files back to a folder to combine and create an inventory list
  • -Use to create a sysprep batch file that would allow you to set the computer name during sysprep to the asset tag and then have it join the domain using the netdom.exe application (not natively in windows).
  • -This batch file can easily be modified to get any WMIC value; just open up a command prompt and type: WMIC <enter>  then type /? to get a full list of available parameters.
 

About Jimmy Selix

Jimmy Selix is an early adopter that loves to be one of the first on the block to have the latest and greatest in technology and gadgets. Another love of his is being able to share his knowledge to others seeking it. Feel free to drop any comments or questions that you may have.
View more articles by Jimmy Selix

The Conversation

Follow the reactions below and share your own thoughts.

5 Responses to “Batch File: How to retrieve Asset Tag / Serial Number for a Dell computer”

  1. October 05, 2010 at 1:39 am, Rob Rogers said:

    Great rx!

    Reply

  2. October 05, 2010 at 12:27 pm, David Kirk - Founder/Editor said:

    Very cool!

    Reply

  3. October 07, 2010 at 11:07 am, Javenzhi said:

    good

    Reply

  4. November 13, 2010 at 12:24 pm, used dell computers said:

    Indeed a very good read! Very informative post with pretty good insight on all aspects of the topic! Will keep visiting in future too!

    Reply

  5. March 09, 2012 at 6:51 am, Equin said:

    Awesome script, to get the asset tag just change serialnumber for SMBIOSAssetTag

    Reply

Leave a Reply