Jump to content

serial number as computername during unattended


Recommended Posts

I have received so much useful info from this site that I though I would post something that I hope is useful for someone. :)

I have all COmpaq computers and wanted to name them the serial number during an unattended setup to keep uniqueness. I placed this vbscript in the runonceex and it places the serial number in the sysprep.inf as the computername. The original syspre.inf has a computername of #### which will be replaced with the serial number.

'prep

dim Bios, BiosSerial, objFSO, objTextFile

'Const ForReading = 1, ForWriting = 2, ForAppending = 8

'get serial number

for each Bios in GetObject("winmgmts:").InstancesOf ("win32_bios")

BiosSerial = Bios.SerialNumber

exit for

next

'open file and read into memory, replace #### with serialnumber

Set objFSO = CreateObject("Scripting.FileSystemObject")

r="c:\sysprep\sysprep.inf"

Set objTextFile = objFSO.OpenTextFile(r,1)

s = objtextfile.readall

x = "####"

snew = Replace(s,x,biosserial)

objTextFile.close

set objtextfile=nothing

'delete old file

objfso.DeleteFile r, true

'write new file

set objTextFile = objfso.CreateTextFile®

objTextFile.Write snew

objTextFile.Close

set objTextFile = nothing

'messagebox

'msgbox "Computername changed to " + BiosSerial + "...", yes

Mike Niccum

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...