mniccum Posted January 20, 2004 Posted January 20, 2004 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.'prepdim Bios, BiosSerial, objFSO, objTextFile'Const ForReading = 1, ForWriting = 2, ForAppending = 8'get serial numberfor each Bios in GetObject("winmgmts:").InstancesOf ("win32_bios") BiosSerial = Bios.SerialNumber exit fornext'open file and read into memory, replace #### with serialnumberSet objFSO = CreateObject("Scripting.FileSystemObject")r="c:\sysprep\sysprep.inf"Set objTextFile = objFSO.OpenTextFile(r,1)s = objtextfile.readallx = "####"snew = Replace(s,x,biosserial) objTextFile.closeset objtextfile=nothing'delete old fileobjfso.DeleteFile r, true'write new fileset objTextFile = objfso.CreateTextFile®objTextFile.Write snewobjTextFile.Closeset objTextFile = nothing'messagebox'msgbox "Computername changed to " + BiosSerial + "...", yesMike Niccum
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now