The goal:
To use Sysprep with an answer file to restore an image to a new PC, without having to baby-sit the process. This would include renaming the computer based on the "SerialNumber" field in the BIOS.
The problem:
I've got a simple VB script already that will pull the SerialNumber from the BIOS, but now I can't figure out how to use the information to rename the system. Specifically, the computer name will need to be "CompanyName-SerialNumber". Is there an easy way to perform the rename within the same script that I use to pull the SerialNumber out of the BIOS?
Note: I don't need to join these computers to a domain - this is for preparing multiple systems for a customer who will use them stand-alone.
My existing script that pulls the SerialNumber is below. Right now, I have it set to port the output to a text file, and one of our developers wrote a little program to parse the file and rename the computer, but this is not as elegant as I think it could be. Since I don't know how to write script yet, I pieced this together from Scriptomatic and some samples from the Web.
Script:
filePath = "C:\"
filePrefix = "ID"
fileExt = ".txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(filePath & filePrefix & fileExt)
arrComputers = Array(".")
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
objFile.WriteLine objItem.SerialNumber
Next
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
Thanks in advance for any help,
Nathan



Help
Back to top









