mniccum Posted January 20, 2004 Share 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now