How to edit the Unattend with a custom Asset based computer name during setup?

I really hope someone has tackled this in Windows 8.1...

So with the "no computer name prompt" in Windows 7/8 we have had trouble in the past with naming the computers (we deploy hundreds per month, this next project is for 6500) So our base image has everything configured just plug into the network and boot, we want it to name it a Pre-fix + Asset. I have all the scripts written and they work great - it checks the Asset tag field in bios from a WMI query and than uses "RR"+AssetTag as a variable, than it reads the unattned.xml file and replaces the computer name ("name_this") in the unattend.xml

However.... I am having trouble getting the script to run during the setup, it seems to never change the "name_this"

This is my unattned.xml (any help is appreciated) - shortened

   <settings pass="specialize">
        <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Path>net user administrator /active:yes</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
            <RunAsynchronous>
                <RunAsynchronousCommand wcm:action="add">
                    <Description>Rename &quot;name_this&quot; in unattend</Description>
                    <Order>1</Order>
                    <Path>cscript.exe %systemroot%\System32\Sysprep\customsysprep\EditUnattend.vbs</Path>
                </RunAsynchronousCommand>
            </RunAsynchronous>
        </component>
        <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SkipAutoActivation>true</SkipAutoActivation>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <CopyProfile>true</CopyProfile>
            <TimeZone>Pacific Standard Time</TimeZone>
            <ComputerName>name_this</ComputerName>
        </component>

Here is my script..

Dim answer, strcomputerName, unattendFile, WshShell, fso, unattendFileObject, strContents, assetfile, AssetFileObject, Asset


arrComputers = Array("NAME_THIS")

unattendFile = "C:\Windows\Panther\unattend.xml"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

For Each strComputer In arrComputers
     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", _
                wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      Asset="RR" & objItem.SMBIOSAssetTag

Next
Next
Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
strContents = unattendFileObject.ReadAll
strContents = Replace(strContents, "name_this", Asset)
strContents = Replace(strContents, "USERASSETDATA.ASSET_NUMBER=", "RR")
unattendFileObject.Close
Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
unattendFileObject.Write(strContents)
unattendFileObject.Close

'For testing the script
WScript.Echo Asset

November 30th, 2013 3:06am

Hi,

According to the information you provided, we could judge the culprit is the "script".

For issue about script, wed recommend you ask script forum for professional solution:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Free Windows Admin Tool Kit Click here and download it now
December 2nd, 2013 10:39am

you should check this out mysysprep2, its a lot easier to use, only requires the unattend file and no additional scripts to name a computer with the asset tag included
December 12th, 2013 4:17pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics