+ Post New Thread
Results 1 to 8 of 8
Windows Thread, Pulling serial no from BIOS into Sysprep in Technical; We have to use an archaic method of PC deployment at my current place of work due to geographic network ...
  1. #1
    mark's Avatar
    Join Date
    Jun 2005
    Posts
    3,946
    Thank Post
    235
    Thanked 48 Times in 44 Posts
    Blog Entries
    2
    Rep Power
    45

    Question Pulling serial no from BIOS into Sysprep

    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:
    Code:
    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

  2. #2

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,692
    Thank Post
    824
    Thanked 2,570 Times in 2,187 Posts
    Blog Entries
    9
    Rep Power
    731
    Check this out, a guy looks to have already written a script to do just that for Dells:

    http://www.archaicbinary.net/file-do...erial-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:
    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
    Last edited by SYNACK; 6th March 2009 at 12:43 PM.

  3. Thanks to SYNACK from:

    mark (6th March 2009)

  4. #3
    mark's Avatar
    Join Date
    Jun 2005
    Posts
    3,946
    Thank Post
    235
    Thanked 48 Times in 44 Posts
    Blog Entries
    2
    Rep Power
    45
    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?

  5. #4

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,692
    Thank Post
    824
    Thanked 2,570 Times in 2,187 Posts
    Blog Entries
    9
    Rep Power
    731
    Quote Originally Posted by mark View Post
    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.

  6. #5
    mark's Avatar
    Join Date
    Jun 2005
    Posts
    3,946
    Thank Post
    235
    Thanked 48 Times in 44 Posts
    Blog Entries
    2
    Rep Power
    45
    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.

  7. #6
    mark's Avatar
    Join Date
    Jun 2005
    Posts
    3,946
    Thank Post
    235
    Thanked 48 Times in 44 Posts
    Blog Entries
    2
    Rep Power
    45
    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

  8. #7

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,692
    Thank Post
    824
    Thanked 2,570 Times in 2,187 Posts
    Blog Entries
    9
    Rep Power
    731
    You will need to have a copy of the cscript.exe from either your installation or in the OEM folder interpret it.

    Code:
    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:

    Code:
    c:\windows\cscript.exe "c:\sysprep\rename.vbs"

  9. #8
    mark's Avatar
    Join Date
    Jun 2005
    Posts
    3,946
    Thank Post
    235
    Thanked 48 Times in 44 Posts
    Blog Entries
    2
    Rep Power
    45
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. Serial Cable Length
    By CyberNerd in forum Hardware
    Replies: 4
    Last Post: 19th November 2008, 04:02 PM
  2. Wireless Approach : Pulling it all together
    By contink in forum Windows Server 2000/2003
    Replies: 2
    Last Post: 19th November 2008, 11:47 AM
  3. Pulling copying fails - push copying works
    By SimpleSi in forum Windows
    Replies: 1
    Last Post: 3rd March 2008, 02:29 PM
  4. Serial SmartBoards
    By tscnmuk in forum Windows
    Replies: 3
    Last Post: 4th December 2007, 10:02 AM
  5. Lost my serial
    By CyberNerd in forum *nix
    Replies: 2
    Last Post: 30th June 2006, 01:27 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •