Windows 7 Sysprep getting serialnumber from bios


I have a sysprep image that prompts for a computerName, changes the machine name and joins it to the domain, all working well.

However, I would like to grab the machine serial number to set as the computerName.  I have found many possibilities from WMI and some VBS scripting which work when I run them on a fully installed machine.  However, If I try to use it in a vbs script that runs before joining the domain (specialize stage), the machine reboots during the setup and never completes its sysprep, essentially corrupting the machine.

I am starting to believe that wmi is not totally available during the specialize stage.  Just curious, any other methods that people have been successful with?
Anthony CarterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Walter CurtisSharePoint AEDCommented:
In the XP days, I used WinPE which supported VBS and WMI. Grabbed the serial number using WMI that read bios, connected to an excel file on a network share (using VBS) to determine the corresponding computer name, then wrote to the computer name in to ini file in the sysprep folder that held info needed to rename the machine and join it to the domain.

Surely something is similar with Win7.

Hope that helps...
ivan rosaCommented:
I know in a batch to get a SN there's this command
    wmic bios get serialnumber

And this for .vbs   --see 

On Error Resume Next
Dim strComputer
strComputer = InputBox("Enter the name of the computer:")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
MsgBox strComputer & ": " & objSMBIOS.SerialNumber
Anthony CarterAuthor Commented:
Ivan:  Yes, I have tried both of those methods and it causes sysprep to crash in the specialize phase.
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

why not set the name/domain join as a bootup script after the sysprep.
ON first boot it will run the system customization/naming .........

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony CarterAuthor Commented:
Hi Arnold,

Yes, I could do this and this is probably the way I am going to go.  Activation against our kms server will also need to be deferred and I was hoping that this could just be done purely in sysprep.  Just throwing out there if anyone had a solution to this or not within sysprep.
ivan rosaCommented:
Here's  crazy thought what about create a separate script before syspep to deliver a the sn in a txt then in syspep link it to it
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.