winpe - sysprep - vbs help

Dell / E6400
February 5, 2009 at 01:30:41
Specs: Windows PE 2.0, intel 4 gig
im trying to write a script that can run within winpe 2.0. to help with changing the computer name to the dell service tag, within sysprep after imaging.

i thinking that i should be able to grab the dell service tag with a script, something like this.

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
  strSN = objSMBIOS.SerialNumber
  If strSN <> "" Then exit For
Next

once im booted into winpe i use imagex to apply the syspreped image. after the image has been applied to the c: drive it is editable, so i should in theory be able to send the dell service tag that was grabbed for the above script to C:\sysprep\sysprep.inf.

within the sysprep.inf there is a computername=

im not sure if it is best to just enter the newly grab computer name, or better to create a variable, if even possible?

a friend of mine gave me the below script, and said it would do just that, however i do not see where the it references the sysprep.inf file, I tested it with no success.

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure",,48)
For Each objItem in colItems
strSTag = objItem.SMBIOSAssetTag
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
err = objComputer.Rename(strSTag)
Next
strPCName = strSTag
Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
intErr = objComputer.Rename(strPCName)
Next

any help in this matter would be greatly appreciated, and im sure this could be used by others in my situation. thank you everyone for your help, unfortunately im pretty new to the vb scripting, but hope to get better through trial and error, thanks again.

d@ve


See More: winpe - sysprep - vbs help

Report •


#1
February 5, 2009 at 15:58:40
is there something im doing wrong with my post that my text and code is so wide? i dont notice that on anyone else posts.

thanks again for the help in advance with the above script.

d@ve


Report •
Related Solutions


Ask Question