MkII Posted March 6, 2009 Posted March 6, 2009 We have to use an archaic method of PC deployment at my current place of work due to geographic network limitations. Currently we configure a PC to a bare spec without Office or specialist software, Sysprep it and image it out from portable HDD. I should add that the network is tied down to mac address and auto joining the domain isn't possible. I've fully automated sysprep, apart from the PC name, which on our exclusively Dell machines, is the service tag. What I want to do is, pull the service tag from the bios and use it as the PC name silently during the sysprep process. Anyone have any ideas? I have this script which get's the service tag: Option Explicit ' Set Local Computer Dim colItems, Computer, objItem, Ts, Z1 Computer = "." Dim Act :Set Act = CreateObject("WScript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Txt :Txt = Act.SpecialFolders("Desktop") & "\Bios.txt" Dim Wmi :Set Wmi = GetObject("winmgmts:\\" & Computer & "\root\CIMV2") Set Ts = Fso.CreateTextFile(Txt) Set colItems = Wmi.ExecQuery("SELECT * FROM Win32_BIOS",,48) For Each objItem in colItems Ts.WriteLine objItem.SerialNumber Next Ts.Close() Act.Run(Chr(34) & Txt & Chr(34)),1,True
SYNACK Posted March 6, 2009 Posted March 6, 2009 (edited) Check this out, a guy looks to have already written a script to do just that for Dells: http://www.archaicbinary.net/file-downloads/change-computer-name-to-serial-vbs.html you should be able to chuck this into the cmdlines.txt chunk with a refference to cscript of course and rename it before it joins the domain. In case the site ever dissapears here is the code: strUser = "Administrator" strPassword = "P@ssw0rd" Set objNetwork = CreateObject("WScript.Network") strComputer = objNetwork.ComputerName Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _ strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _ strComputer & "'") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48) For Each objItem in colItems strMsg = objItem.Caption If strMsg = "Microsoft Windows XP Professional" Then winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//." 'WScript.Echo winmgmt1 Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS") for each SN in SNSet If SN.SerialNumber = strComputer Then MsgBox "Computer name already set! Name is: "& strComputer Wscript.Quit End If If SN.SerialNumber = "" Then MsgBox "Problem with computer naming!" Wscript.Quit End If ErrCode = objComputer.Rename(SN.SerialNumber, strPassword, strUser) If ErrCode = 0 Then MsgBox "Computer renamed successfully to: "& SN.SerialNumber End If Next End If Next Edited March 6, 2009 by SYNACK 1
MkII Posted March 6, 2009 Author Posted March 6, 2009 Wicked, thanks SYNACK. Isn't unattended just for bare installs? (as opposed to sysprep which uses mini setup). This is a preloaded image with utlilities and Office etc installed. At the end of which (sysprep imaging) you have the choices of run once, additional commands and identification string. I suppose running this script at the end with run once would do the job, after giving the PC a temp name in mini setup. Would it have to reboot one more time?
SYNACK Posted March 6, 2009 Posted March 6, 2009 Wicked, thanks SYNACK. Isn't unattended just for bare installs? (as opposed to sysprep which uses mini setup). This is a preloaded image with utlilities and Office etc installed. At the end of which (sysprep imaging) you have the choices of run once, additional commands and identification string. I suppose running this script at the end with run once would do the job, after giving the PC a temp name in mini setup. Would it have to reboot one more time? Yea, not sure on that, I think the GUI setup bit does run on a syspreped image but I am not sure whether it calls the cmdlines during it or not. You should be able to chuck it in the additional comands section though. Not sure on the reboot, might have to try running the script on a computer independantly and seeing if it needs a reboot to pick up the new name. I would try to get the new name picked up before hooking up to AD though as quick renames in AD can cause issues.
MkII Posted March 6, 2009 Author Posted March 6, 2009 The AD bit isn't an issue as I can't join it to the domain until the switches are configured after I've obtained the mac address. PITA but how it's setup here. Thanks a lot for the help, I'll try it and let you know.
MkII Posted March 9, 2009 Author Posted March 9, 2009 ok finally got around to testing. I have this in sysprep.inf [unattended] ;Specifies the location of files which are required during Mini-Setup InstallFilesPath=C:\Sysprep\i386 and in c:\sysprep\i386\$oem$\ I have cmdlines.txt In cmdlines.txt I have the line: "c:\sysprep\i386\$oem$\rename.vbs" ...which is what i've called the above script, minus the error checking. I specified a PC name in Mini Setup so it wouldn't prompt for one, and it should then at the end of Mini Setup rename the PC from the vbs and reboot. It's not working. Anyone spot why? Cheers
SYNACK Posted March 10, 2009 Posted March 10, 2009 You will need to have a copy of the cscript.exe from either your installation or in the OEM folder interpret it. c:\windows\cscript.exe "c:\sysprep\i386\$oem$\rename.vbs" I think that $oem$ actually gets moved to the c: at the start of the procedure (am probably wrong) so the file may have been moved by the time that cmdlines.txt executes. From what I recall everything in the sysprep folder gets deleted when it is finnished runniing and so it may be easier to just dump the script in there directly: c:\windows\cscript.exe "c:\sysprep\rename.vbs"
MkII Posted March 10, 2009 Author Posted March 10, 2009 Ah right. I've seen cscript referenced but didn't know why. Yeah you're right - the sysprep folder gets deleted. Will keep you posted.
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